stdio: Fix a possible buffer overflow
PATCH 1/1 stdio: Fix a possible buffer overflow
Signed-off-by Bradley Bolen <[email protected]>
---
The length of the name of a stdio_dev is 16 bytes, but the local variable to hold it is only 8 bytes. Also, the memcpy should copy the size of the destination, not the size of the source.
--- common/stdio.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
common/stdio.c +2 -2
@@ -160,7 +160,7 @@ int stdio_deregister(const char *devname)int l;struct list_head *pos;struct stdio_dev *dev; -char temp_names[3 ][8 ]; +char temp_names[3 ][16 ]; dev =stdio_get_by_name (devname);
@@ -174,7 +174,7 @@ int stdio_deregister(const char *devname) }memcpy (&temp_names[l][0 ], stdio_devices[l]->name, -sizeof (stdio_devices[l]->name)); +sizeof (temp_names[l])); }list_del (&(dev->list));
Signature · 1 line
1.6.0.5
PATCH 1/1 stdio: Fix a possible buffer overflow
Dear Bradley Bolen,
Quoted 23 lines · In message <[email protected]>…
Signed-off-by Bradley Bolen <[email protected]>---
The length of the name of astdio_devis 16 bytes, but the local variable to hold it is only 8 bytes. Also, the memcpy should copy the size of the destination, not the size of the source.--- common/stdio.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)common/stdio.c +1
-1@@ -160,7 +160,7 @@ int stdio_deregister(const char *devname)int l;struct list_head *pos;struct stdio_dev *dev; -char temp_names[3 ][8 ]; +char temp_names[3 ][16 ]; dev =stdio_get_by_name (devname);
common/stdio.c int stdio_deregister(const char *devname) · line 177
Quoted 5 lines
common/stdio.c +1
-1@@ -174,7 +174,7 @@ int stdio_deregister(const char *devname) }memcpy (&temp_names[l][0 ], stdio_devices[l]->name, -sizeof (stdio_devices[l]->name)); +sizeof (temp_names[l]));
Your patch is white space corrupted. Please make sure to use git-send-email next time (or at least fix your mailer).
Applied manually, thanks.
Best regards,
Wolfgang Denk
Signature · 7 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Digital computers are themselves more complex than most things people build: They have very large numbers of states. This makes conceiving, describing, and testing them hard. Software systems have orders-of- magnitude more states than computers do. - Fred Brooks, Jr.