libmount: check errno after strto..()
Addresses: https://github.com/karelzak/util-linux/issues/1356 Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
0395e8f7d7
commit
5aa726461a
|
@ -220,9 +220,12 @@ PyMODINIT_FUNC initpylibmount(void)
|
|||
if (!(pylibmount_debug_mask & PYMNT_DEBUG_INIT)) {
|
||||
char *str = getenv("PYLIBMOUNT_DEBUG");
|
||||
|
||||
errno = 0;
|
||||
pylibmount_debug_mask = 0;
|
||||
if (str)
|
||||
pylibmount_debug_mask = strtoul(str, NULL, 0);
|
||||
if (errno)
|
||||
pylibmount_debug_mask = 0;
|
||||
|
||||
pylibmount_debug_mask |= PYMNT_DEBUG_INIT;
|
||||
}
|
||||
|
|
|
@ -61,8 +61,9 @@ static size_t crypt_hex_to_bytes(const char *hex, char **result)
|
|||
|
||||
for (i = 0; i < len; i++) {
|
||||
memcpy(buf, &hex[i * 2], 2);
|
||||
errno = 0;
|
||||
bytes[i] = strtoul(buf, &endp, 16);
|
||||
if (endp != &buf[2]) {
|
||||
if (errno || endp != &buf[2]) {
|
||||
free(bytes);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
@ -50,11 +50,12 @@ static const char *next_s32(const char *s, int *num, int *rc)
|
|||
if (!s || !*s)
|
||||
return s;
|
||||
|
||||
errno = 0;
|
||||
*rc = -EINVAL;
|
||||
*num = strtol(s, &end, 10);
|
||||
if (end == NULL || s == end)
|
||||
return s;
|
||||
if (*end == ' ' || *end == '\t' || *end == '\0')
|
||||
if (errno == 0 && (*end == ' ' || *end == '\t' || *end == '\0'))
|
||||
*rc = 0;
|
||||
return end;
|
||||
}
|
||||
|
@ -66,11 +67,12 @@ static const char *next_u64(const char *s, uint64_t *num, int *rc)
|
|||
if (!s || !*s)
|
||||
return s;
|
||||
|
||||
errno = 0;
|
||||
*rc = -EINVAL;
|
||||
*num = (uint64_t) strtoumax(s, &end, 10);
|
||||
if (end == NULL || s == end)
|
||||
return s;
|
||||
if (*end == ' ' || *end == '\t' || *end == '\0')
|
||||
if (errno == 0 && (*end == ' ' || *end == '\t' || *end == '\0'))
|
||||
*rc = 0;
|
||||
return end;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue