[PATCH] fix integer overflow in util/fcp.c, util/eraseall.c,
Hideki IWAMOTO
h-iwamoto at kit.hi-ho.ne.jp
Fri Mar 26 12:05:29 EST 2004
eraseall and fcp print wrong progress message for large partition (>=41944KB).
Index: eraseall.c
===================================================================
RCS file: /home/cvs/mtd/util/eraseall.c,v
retrieving revision 1.12
diff -u -r1.12 eraseall.c
--- eraseall.c 2 May 2003 19:27:32 -0000 1.12
+++ eraseall.c 26 Mar 2004 16:50:44 -0000
@@ -93,7 +93,7 @@
printf
("\rErasing %d Kibyte @ %x -- %2d %% complete.",
meminfo.erasesize / 1024, erase.start,
- erase.start * 100 / meminfo.size);
+ erase.start / (meminfo.size / 100));
}
fflush(stdout);
Index: fcp.c
===================================================================
RCS file: /home/cvs/mtd/util/fcp.c,v
retrieving revision 1.2
diff -u -r1.2 fcp.c
--- fcp.c 3 Apr 2003 11:43:37 -0000 1.2
+++ fcp.c 26 Mar 2004 16:50:45 -0000
@@ -59,7 +59,7 @@
#endif
#define KB(x) ((x) / 1024)
-#define PERCENTAGE(x,total) (((x) * 100) / (total))
+#define PERCENTAGE(x,total) ((x) / ((total) / 100))
/* size of read/write buffer */
#define BUFSIZE (10 * 1024)
----
Hideki IWAMOTO h-iwamoto at kit.hi-ho.ne.jp
More information about the linux-mtd
mailing list