Commit 83fd2e62 authored by Alessandro Rubini's avatar Alessandro Rubini

mch_flasher: bugfix in argument parsing

we'd better err out than corrupt memory, if we have more arguments than
expected
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 9cf5ce2e
......@@ -51,6 +51,10 @@
#define MEMTYPE_DF 1
#define MEMTYPE_NAND 2
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
#endif
const char* memName[3] = { "DDR", "DataFlash", "NandFlash" };
......@@ -604,6 +608,11 @@ main(int argc, char *argv[])
//Obtain the various filename & offset (3 MAX)
for(nFile=0; optind < argc; nFile++)
{
if (nFile >= ARRAY_SIZE(filearray)) {
fprintf(stderr, "%s: too may arguments\n",
argv[0]);
exit(1);
}
filearray[nFile].fname=argv[optind++];
filearray[nFile].offset=getOffset(argv[optind++]);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment