aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2013-02-28 10:42:26 +0100
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2013-03-11 09:51:29 +0200
commit1145ef7ee979dde2d611e09d00fc6ff0090dcc9d (patch)
tree4d9ddf29f2841957f9d8b2fbc9612110e607b070
parent86cf5bd1e0633f16c722500bd9717d999a7e2473 (diff)
flash_otp_write: fix a buffer overflow on NAND with write size > 2048
I'm not aware of any chip having a write size bigger than 2048 today. Still checking for that instead of a sleeping problem to bite us maybe in a few years is easy. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
-rw-r--r--flash_otp_write.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/flash_otp_write.c b/flash_otp_write.c
index 3515eee..eaca5e1 100644
--- a/flash_otp_write.c
+++ b/flash_otp_write.c
@@ -83,6 +83,12 @@ int main(int argc,char *argv[])
else
len = 256;
+ if (len > sizeof(buf)) {
+ printf("huh, writesize (%d) bigger than buffer (%zu)\n",
+ len, sizeof(buf));
+ return ENOMEM;
+ }
+
wrote = 0;
while ((size = xread(0, buf, len))) {
if (size < 0) {