Alexey Dobriyan | 3ee2a19 | 2017-11-17 15:26:49 -0800 | [diff] [blame] | 1 | #include <linux/dcache.h> |
Eric Biggers | 81966d83 | 2019-01-03 15:26:00 -0800 | [diff] [blame] | 2 | #include "internal.h" |
Alexey Dobriyan | 3ee2a19 | 2017-11-17 15:26:49 -0800 | [diff] [blame] | 3 | |
| 4 | unsigned name_to_int(const struct qstr *qstr) |
| 5 | { |
| 6 | const char *name = qstr->name; |
| 7 | int len = qstr->len; |
| 8 | unsigned n = 0; |
| 9 | |
| 10 | if (len > 1 && *name == '0') |
| 11 | goto out; |
Alexey Dobriyan | 0746a0b | 2017-11-17 15:26:52 -0800 | [diff] [blame] | 12 | do { |
Alexey Dobriyan | 3ee2a19 | 2017-11-17 15:26:49 -0800 | [diff] [blame] | 13 | unsigned c = *name++ - '0'; |
| 14 | if (c > 9) |
| 15 | goto out; |
| 16 | if (n >= (~0U-9)/10) |
| 17 | goto out; |
| 18 | n *= 10; |
| 19 | n += c; |
Alexey Dobriyan | 0746a0b | 2017-11-17 15:26:52 -0800 | [diff] [blame] | 20 | } while (--len > 0); |
Alexey Dobriyan | 3ee2a19 | 2017-11-17 15:26:49 -0800 | [diff] [blame] | 21 | return n; |
| 22 | out: |
| 23 | return ~0U; |
| 24 | } |