Commit a7a4f1c1a52912eb8b3bd4d8f628d83a8b5d69dd
Committed by
David S. Miller
1 parent
fb8621bb6c
Exists in
master
and in
39 other branches
drivers: isdn: capi: use simple_strtol to convert numbers
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com> Cc: Karsten Keil <isdn@linux-pingi.de> Cc: Tilman Schmidt <tilman@imap.cc> Cc: netdev@vger.kernel.org Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 1 changed file with 13 additions and 4 deletions Side-by-side Diff
drivers/isdn/capi/capidrv.c
... | ... | @@ -1515,8 +1515,13 @@ |
1515 | 1515 | while (*s) { |
1516 | 1516 | int digit1 = 0; |
1517 | 1517 | int digit2 = 0; |
1518 | - if (!isdigit(*s)) return -3; | |
1519 | - while (isdigit(*s)) { digit1 = digit1*10 + (*s - '0'); s++; } | |
1518 | + char *endp; | |
1519 | + | |
1520 | + digit1 = simple_strtoul(s, &endp, 10); | |
1521 | + if (s == endp) | |
1522 | + return -3; | |
1523 | + s = endp; | |
1524 | + | |
1520 | 1525 | if (digit1 <= 0 || digit1 > 30) return -4; |
1521 | 1526 | if (*s == 0 || *s == ',' || *s == ' ') { |
1522 | 1527 | bmask |= (1 << digit1); |
... | ... | @@ -1526,8 +1531,12 @@ |
1526 | 1531 | } |
1527 | 1532 | if (*s != '-') return -5; |
1528 | 1533 | s++; |
1529 | - if (!isdigit(*s)) return -3; | |
1530 | - while (isdigit(*s)) { digit2 = digit2*10 + (*s - '0'); s++; } | |
1534 | + | |
1535 | + digit2 = simple_strtoul(s, &endp, 10); | |
1536 | + if (s == endp) | |
1537 | + return -3; | |
1538 | + s = endp; | |
1539 | + | |
1531 | 1540 | if (digit2 <= 0 || digit2 > 30) return -4; |
1532 | 1541 | if (*s == 0 || *s == ',' || *s == ' ') { |
1533 | 1542 | if (digit1 > digit2) |