public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] FAT: buffer overflow with FAT12/16
@ 2010-10-20  6:51 Stefano Babic
  2010-10-20  7:15 ` Wolfgang Denk
  2010-10-20  7:23 ` Mikhail Zolotaryov
  0 siblings, 2 replies; 3+ messages in thread
From: Stefano Babic @ 2010-10-20  6:51 UTC (permalink / raw)
  To: u-boot

Last commit 3831530dcb7b71329c272ccd6181f8038b6a6dd0a was intended
"explicitly specify FAT12/16 root directory parsing buffer size, instead
of relying on cluster size". Howver, the underlying function requires
the size of the buffer in blocks, not in bytes, and instead of passing
a double sector size a request for 1024 blocks is sent. This generates
a buffer overflow with overwriting of other structure (in the case seen,
USB structures were overwritten).

Signed-off-by: Stefano Babic <sbabic@denx.de>
CC: Mikhail Zolotaryov <lebon@lebon.org.ua>

---
 fs/fat/fat.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 744e961..a75e4f2 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -858,7 +858,7 @@ do_fat_read (const char *filename, void *buffer, unsigned long maxsize,
 		if (disk_read(cursect,
 				(mydata->fatsize == 32) ?
 				(mydata->clust_size) :
-				LINEAR_PREFETCH_SIZE,
+				LINEAR_PREFETCH_SIZE / SECTOR_SIZE,
 				do_fat_read_block) < 0) {
 			debug("Error: reading rootdir block\n");
 			return -1;
-- 
1.7.1

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

end of thread, other threads:[~2010-10-20  7:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-20  6:51 [U-Boot] [PATCH] FAT: buffer overflow with FAT12/16 Stefano Babic
2010-10-20  7:15 ` Wolfgang Denk
2010-10-20  7:23 ` Mikhail Zolotaryov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox