From: Zachary T Welch Date: Fri, 20 Nov 2009 02:11:30 +0000 (-0800) Subject: fix flash/nand name parsing X-Git-Tag: v0.4.0-rc1~479 X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=commitdiff_plain;h=153848e6cc79241a8da51c1b601c13722b5380a6 fix flash/nand name parsing Start driver.num check from end, and make sure the numeric part is actually a number. Fix problems trying to parse bank names. --- diff --git a/src/flash/common.c b/src/flash/common.c index 253ed9d875..072e6912fd 100644 --- a/src/flash/common.c +++ b/src/flash/common.c @@ -25,9 +25,11 @@ 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