mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-03-05 03:00:39 +01:00
libnm: return 0 for empty address in hwaddr_binary_len()
Motivated by avoiding compiler warning with -O2 -Wstrict-overflow (gcc-4.8.3):
make[4]: Entering directory `./NetworkManager/libnm-core'
CC nm-utils.lo
../libnm-core/nm-utils.c: In function 'nm_utils_hwaddr_valid':
../libnm-core/nm-utils.c:2725:14: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
if (length == 0 || length > NM_UTILS_HWADDR_LEN_MAX)
^
../libnm-core/nm-utils.c: In function 'nm_utils_hwaddr_canonical':
../libnm-core/nm-utils.c:2755:14: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
if (length == 0 || length > NM_UTILS_HWADDR_LEN_MAX)
^
https://bugzilla.gnome.org/show_bug.cgi?id=741168
This commit is contained in:
parent
5bfb4c8c23
commit
937a5639fc
1 changed files with 5 additions and 2 deletions
|
|
@ -2693,6 +2693,9 @@ hwaddr_binary_len (const char *asc)
|
|||
{
|
||||
int octets = 1;
|
||||
|
||||
if (!*asc)
|
||||
return 0;
|
||||
|
||||
for (; *asc; asc++) {
|
||||
if (*asc == ':' || *asc == '-')
|
||||
octets++;
|
||||
|
|
@ -2827,7 +2830,7 @@ nm_utils_hwaddr_matches (gconstpointer hwaddr1,
|
|||
g_return_val_if_fail (hwaddr1 != NULL, FALSE);
|
||||
|
||||
hwaddr1_len = hwaddr_binary_len (hwaddr1);
|
||||
if (hwaddr1_len > NM_UTILS_HWADDR_LEN_MAX)
|
||||
if (hwaddr1_len == 0 || hwaddr1_len > NM_UTILS_HWADDR_LEN_MAX)
|
||||
return FALSE;
|
||||
if (!nm_utils_hwaddr_aton (hwaddr1, buf1, hwaddr1_len))
|
||||
return FALSE;
|
||||
|
|
@ -2880,7 +2883,7 @@ _nm_utils_hwaddr_to_dbus (const GValue *prop_value)
|
|||
|
||||
if (str) {
|
||||
len = hwaddr_binary_len (str);
|
||||
g_return_val_if_fail (len <= NM_UTILS_HWADDR_LEN_MAX, NULL);
|
||||
g_return_val_if_fail (len > 0 && len <= NM_UTILS_HWADDR_LEN_MAX, NULL);
|
||||
if (!nm_utils_hwaddr_aton (str, buf, len))
|
||||
len = 0;
|
||||
} else
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue