mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2025-01-31 01:04:03 -05:00
Check os_snprintf() result more consistently - maximum length
This adds verification of os_snprintf() result against the maximum buffer length. These changes were done automatically with spatch using the following semantic patch: @@ expression E1,E2,E3; statement S1; @@ E1 = os_snprintf(E2, E3, ...); - if (\( E1 < 0 \| E1 <= 0 \)) + if (os_snprintf_error(E3, E1)) ( S1 | { ... } ) Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
0047306bc9
commit
a9aaacbb50
@ -7972,7 +7972,7 @@ static int linux_write_system_file(const char *path, unsigned int val)
|
|||||||
int fd, len;
|
int fd, len;
|
||||||
|
|
||||||
len = os_snprintf(buf, sizeof(buf), "%u\n", val);
|
len = os_snprintf(buf, sizeof(buf), "%u\n", val);
|
||||||
if (len < 0)
|
if (os_snprintf_error(sizeof(buf), len))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
fd = open(path, O_WRONLY);
|
fd = open(path, O_WRONLY);
|
||||||
|
@ -247,7 +247,7 @@ dbus_bool_t set_network_properties(struct wpa_supplicant *wpa_s,
|
|||||||
|
|
||||||
ret = os_snprintf(value, size, "%u",
|
ret = os_snprintf(value, size, "%u",
|
||||||
entry.uint32_value);
|
entry.uint32_value);
|
||||||
if (ret <= 0)
|
if (os_snprintf_error(size, ret))
|
||||||
goto error;
|
goto error;
|
||||||
} else if (entry.type == DBUS_TYPE_INT32) {
|
} else if (entry.type == DBUS_TYPE_INT32) {
|
||||||
value = os_zalloc(size);
|
value = os_zalloc(size);
|
||||||
@ -256,7 +256,7 @@ dbus_bool_t set_network_properties(struct wpa_supplicant *wpa_s,
|
|||||||
|
|
||||||
ret = os_snprintf(value, size, "%d",
|
ret = os_snprintf(value, size, "%d",
|
||||||
entry.int32_value);
|
entry.int32_value);
|
||||||
if (ret <= 0)
|
if (os_snprintf_error(size, ret))
|
||||||
goto error;
|
goto error;
|
||||||
} else
|
} else
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -981,7 +981,7 @@ DBusMessage * wpas_dbus_iface_set_network(DBusMessage *message,
|
|||||||
goto error;
|
goto error;
|
||||||
ret = os_snprintf(value, size, "%u",
|
ret = os_snprintf(value, size, "%u",
|
||||||
entry.uint32_value);
|
entry.uint32_value);
|
||||||
if (ret <= 0)
|
if (os_snprintf_error(size, ret))
|
||||||
goto error;
|
goto error;
|
||||||
} else if (entry.type == DBUS_TYPE_INT32) {
|
} else if (entry.type == DBUS_TYPE_INT32) {
|
||||||
value = os_zalloc(size);
|
value = os_zalloc(size);
|
||||||
@ -989,7 +989,7 @@ DBusMessage * wpas_dbus_iface_set_network(DBusMessage *message,
|
|||||||
goto error;
|
goto error;
|
||||||
ret = os_snprintf(value, size, "%d",
|
ret = os_snprintf(value, size, "%d",
|
||||||
entry.int32_value);
|
entry.int32_value);
|
||||||
if (ret <= 0)
|
if (os_snprintf_error(size, ret))
|
||||||
goto error;
|
goto error;
|
||||||
} else
|
} else
|
||||||
goto error;
|
goto error;
|
||||||
|
Loading…
Reference in New Issue
Block a user