diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2013-02-28 10:42:26 +0100 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2013-03-11 09:51:29 +0200 |
commit | 1145ef7ee979dde2d611e09d00fc6ff0090dcc9d (patch) | |
tree | 4d9ddf29f2841957f9d8b2fbc9612110e607b070 /flash_otp_write.c | |
parent | 86cf5bd1e0633f16c722500bd9717d999a7e2473 (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>
Diffstat (limited to 'flash_otp_write.c')
-rw-r--r-- | flash_otp_write.c | 6 |
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) { |