mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-04-28 06:46:42 -04:00
spa: add and use spa_overflow macros
This commit is contained in:
parent
84f8230a47
commit
0f8d5c6e57
16 changed files with 149 additions and 50 deletions
|
|
@ -11,6 +11,7 @@
|
|||
#include <netdb.h>
|
||||
|
||||
#include <spa/utils/result.h>
|
||||
#include <spa/utils/overflow.h>
|
||||
#include <spa/debug/mem.h>
|
||||
|
||||
#include "config.h"
|
||||
|
|
@ -644,9 +645,8 @@ static int handle_input(struct pw_websocket_connection *conn)
|
|||
current)) < 0)
|
||||
return res;
|
||||
|
||||
if (conn->data_wanted > SIZE_MAX - res)
|
||||
if (spa_overflow_add(conn->data_wanted, (size_t)res, &conn->data_wanted))
|
||||
return -EOVERFLOW;
|
||||
conn->data_wanted += res;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -1020,14 +1020,14 @@ int pw_websocket_connection_send(struct pw_websocket_connection *conn, uint8_t o
|
|||
size_t payload_length = 0;
|
||||
|
||||
for (i = 0; i < iov_len; i++) {
|
||||
if (payload_length > SIZE_MAX - iov[i].iov_len)
|
||||
if (spa_overflow_add(payload_length, iov[i].iov_len, &payload_length))
|
||||
return -EOVERFLOW;
|
||||
payload_length += iov[i].iov_len;
|
||||
}
|
||||
if (payload_length > SIZE_MAX - sizeof(*msg) - 14)
|
||||
size_t alloc_size;
|
||||
if (spa_overflow_add(payload_length, sizeof(*msg) + 14, &alloc_size))
|
||||
return -EOVERFLOW;
|
||||
|
||||
if ((msg = calloc(1, sizeof(*msg) + 14 + payload_length)) == NULL)
|
||||
if ((msg = calloc(1, alloc_size)) == NULL)
|
||||
return -errno;
|
||||
|
||||
d = msg->data;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue