diff options
Diffstat (limited to 'lib/vsprintf.c')
-rw-r--r-- | lib/vsprintf.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index b8a2f549ab0e..7af9d841c43b 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -146,19 +146,16 @@ int strict_strtoul(const char *cp, unsigned int base, unsigned long *res) | |||
146 | { | 146 | { |
147 | char *tail; | 147 | char *tail; |
148 | unsigned long val; | 148 | unsigned long val; |
149 | size_t len; | ||
150 | 149 | ||
151 | *res = 0; | 150 | *res = 0; |
152 | len = strlen(cp); | 151 | if (!*cp) |
153 | if (len == 0) | ||
154 | return -EINVAL; | 152 | return -EINVAL; |
155 | 153 | ||
156 | val = simple_strtoul(cp, &tail, base); | 154 | val = simple_strtoul(cp, &tail, base); |
157 | if (tail == cp) | 155 | if (tail == cp) |
158 | return -EINVAL; | 156 | return -EINVAL; |
159 | 157 | ||
160 | if ((*tail == '\0') || | 158 | if ((tail[0] == '\0') || (tail[0] == '\n' && tail[1] == '\0')) { |
161 | ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) { | ||
162 | *res = val; | 159 | *res = val; |
163 | return 0; | 160 | return 0; |
164 | } | 161 | } |
@@ -220,18 +217,15 @@ int strict_strtoull(const char *cp, unsigned int base, unsigned long long *res) | |||
220 | { | 217 | { |
221 | char *tail; | 218 | char *tail; |
222 | unsigned long long val; | 219 | unsigned long long val; |
223 | size_t len; | ||
224 | 220 | ||
225 | *res = 0; | 221 | *res = 0; |
226 | len = strlen(cp); | 222 | if (!*cp) |
227 | if (len == 0) | ||
228 | return -EINVAL; | 223 | return -EINVAL; |
229 | 224 | ||
230 | val = simple_strtoull(cp, &tail, base); | 225 | val = simple_strtoull(cp, &tail, base); |
231 | if (tail == cp) | 226 | if (tail == cp) |
232 | return -EINVAL; | 227 | return -EINVAL; |
233 | if ((*tail == '\0') || | 228 | if ((tail[0] == '\0') || (tail[0] == '\n' && tail[1] == '\0')) { |
234 | ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) { | ||
235 | *res = val; | 229 | *res = val; |
236 | return 0; | 230 | return 0; |
237 | } | 231 | } |
@@ -980,6 +974,11 @@ char *uuid_string(char *buf, char *end, const u8 *addr, | |||
980 | * [0][1][2][3]-[4][5]-[6][7]-[8][9]-[10][11][12][13][14][15] | 974 | * [0][1][2][3]-[4][5]-[6][7]-[8][9]-[10][11][12][13][14][15] |
981 | * little endian output byte order is: | 975 | * little endian output byte order is: |
982 | * [3][2][1][0]-[5][4]-[7][6]-[8][9]-[10][11][12][13][14][15] | 976 | * [3][2][1][0]-[5][4]-[7][6]-[8][9]-[10][11][12][13][14][15] |
977 | * - 'V' For a struct va_format which contains a format string * and va_list *, | ||
978 | * call vsnprintf(->format, *->va_list). | ||
979 | * Implements a "recursive vsnprintf". | ||
980 | * Do not use this feature without some mechanism to verify the | ||
981 | * correctness of the format string and va_list arguments. | ||
983 | * | 982 | * |
984 | * Note: The difference between 'S' and 'F' is that on ia64 and ppc64 | 983 | * Note: The difference between 'S' and 'F' is that on ia64 and ppc64 |
985 | * function pointers are really function descriptors, which contain a | 984 | * function pointers are really function descriptors, which contain a |
@@ -1025,6 +1024,10 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, | |||
1025 | break; | 1024 | break; |
1026 | case 'U': | 1025 | case 'U': |
1027 | return uuid_string(buf, end, ptr, spec, fmt); | 1026 | return uuid_string(buf, end, ptr, spec, fmt); |
1027 | case 'V': | ||
1028 | return buf + vsnprintf(buf, end - buf, | ||
1029 | ((struct va_format *)ptr)->fmt, | ||
1030 | *(((struct va_format *)ptr)->va)); | ||
1028 | } | 1031 | } |
1029 | spec.flags |= SMALL; | 1032 | spec.flags |= SMALL; |
1030 | if (spec.field_width == -1) { | 1033 | if (spec.field_width == -1) { |