fix flash/nand name parsing
authorZachary T Welch <zw@superlucidity.net>
Fri, 20 Nov 2009 02:11:30 +0000 (18:11 -0800)
committerZachary T Welch <zw@superlucidity.net>
Fri, 20 Nov 2009 15:10:55 +0000 (07:10 -0800)
Start driver.num check from end, and make sure the numeric part is
actually a number.  Fix problems trying to parse bank names.

src/flash/common.c

index 253ed9d875b4dfda15bd1df21a2da2b60782b41b..072e6912fd45079dff8ca4d76270fd9993233991 100644 (file)
 
 unsigned get_flash_name_index(const char *name)
 {
-       const char *index = strchr(name, '.');
+       const char *index = strrchr(name, '.');
        if (NULL == index)
                return 0;
+       if (index[1] < '0' || index[1] > '9')
+               return ~0U;
        unsigned requested;
        int retval = parse_uint(index + 1, &requested);
        // detect parsing error by forcing past end of bank list