mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-03 06:47:04 -04:00
security: fix integer truncation in peer_name alloca size
Memory Safety: Medium The strlen() return value (size_t) is stored in an int before being passed to alloca(). If a malicious client sets an extremely long PW_KEY_NODE_NAME property, the addition could overflow the int, resulting in a small or negative alloca size and a subsequent buffer overflow in snprintf(). Change the type to size_t and add a bounds check to prevent excessively large stack allocations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d60ae4a1df
commit
a9f1ad414e
1 changed files with 6 additions and 4 deletions
|
|
@ -863,10 +863,12 @@ static void manager_added(void *data, struct pw_manager_object *o)
|
||||||
peer_name = "unknown";
|
peer_name = "unknown";
|
||||||
if (peer_name && s->direction == PW_DIRECTION_INPUT &&
|
if (peer_name && s->direction == PW_DIRECTION_INPUT &&
|
||||||
pw_manager_object_is_monitor(peer)) {
|
pw_manager_object_is_monitor(peer)) {
|
||||||
int len = strlen(peer_name) + 10;
|
size_t len = strlen(peer_name) + 10;
|
||||||
char *tmp = alloca(len);
|
if (len <= 1024) {
|
||||||
snprintf(tmp, len, "%s.monitor", peer_name);
|
char *tmp = alloca(len);
|
||||||
peer_name = tmp;
|
snprintf(tmp, len, "%s.monitor", peer_name);
|
||||||
|
peer_name = tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (peer_name != NULL)
|
if (peer_name != NULL)
|
||||||
stream_send_moved(s, peer->index, peer_name);
|
stream_send_moved(s, peer->index, peer_name);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue