summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2019-08-23 11:25:31 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-09-02 09:12:30 +0200
commit75a74b5c107b3bc30f9c3836208f4c17f9309eed (patch)
tree7e26a790234943bf84c46a1bd37ce4c84f84ed3c /include
parentd421771bcea063b9bce551e06552067b9074d015 (diff)
downloadbarebox-75a74b5c107b3bc30f9c3836208f4c17f9309eed.tar.gz
barebox-75a74b5c107b3bc30f9c3836208f4c17f9309eed.tar.xz
console: fix out-of-bounds read in dputc(/dev/*, ...)
Trying to output a single character via echo -a /dev/serial0-1 currently results in garbage output after the newline, because console.c's fops_write discards the buffer length and passes the buffer to (struct cdev)::puts which only handles NUL-terminated strings. Fix this by amending (struct cdev)::puts with a new nbytes parameter, which is correctly propagated. All this functions now return at most the nbytes parameter they were passed in. This fixes __console_puts, which used to count new lines twice in its return value. Fixes: b4f55fcf35 ("console: expose consoles in devfs") Cc: Bastian Krause <bst@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r--include/console.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/console.h b/include/console.h
index 4062e5abf6..7afe59e93a 100644
--- a/include/console.h
+++ b/include/console.h
@@ -42,7 +42,7 @@ struct console_device {
int (*tstc)(struct console_device *cdev);
void (*putc)(struct console_device *cdev, char c);
- int (*puts)(struct console_device *cdev, const char *s);
+ int (*puts)(struct console_device *cdev, const char *s, size_t nbytes);
int (*getc)(struct console_device *cdev);
int (*setbrg)(struct console_device *cdev, int baudrate);
void (*flush)(struct console_device *cdev);