linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] HID: picoLCD: off by one in dump_buff_as_hex()
@ 2012-09-14 11:04 Dan Carpenter
  2012-09-17 20:54 ` Bruno Prémont
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2012-09-14 11:04 UTC (permalink / raw)
  To: Bruno Prémont; +Cc: Jiri Kosina, linux-input, kernel-janitors

We're placing the NUL terminator one character beyond the end of the
buffer here.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This change obviously don't make the code worse, but I'm not positive
it's the right fix.  I'm not sure the lines before are doing the right
thing either, if we had two chars of remaining space then wouldn't it be
better to put the new line and NUL in the unused space?

If you decide to do it differently, then please feel to sent a patch for
that and give me a Reported-by cookie.

diff --git a/drivers/hid/hid-picolcd_debugfs.c b/drivers/hid/hid-picolcd_debugfs.c
index eec85b5..ff271ff0 100644
--- a/drivers/hid/hid-picolcd_debugfs.c
+++ b/drivers/hid/hid-picolcd_debugfs.c
@@ -390,7 +390,7 @@ static void dump_buff_as_hex(char *dst, size_t dst_sz, const u8 *data,
 		dst[j--] = '\0';
 		dst[j] = '\n';
 	} else
-		dst[j] = '\0';
+		dst[dst_sz - 1] = '\0';
 }
 
 void picolcd_debug_out_report(struct picolcd_data *data,

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-09-24 21:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-14 11:04 [patch] HID: picoLCD: off by one in dump_buff_as_hex() Dan Carpenter
2012-09-17 20:54 ` Bruno Prémont
2012-09-19 19:35   ` Bruno Prémont
2012-09-22 12:55     ` Dan Carpenter
2012-09-24 21:07       ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).