mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
connection: guard against fd overflow
This commit is contained in:
parent
8fbcb0fef1
commit
5440435405
4 changed files with 9 additions and 4 deletions
|
|
@ -28,7 +28,7 @@
|
|||
#include "connection.h"
|
||||
#include "log.h"
|
||||
|
||||
#define MAX_BUFFER_SIZE 1024
|
||||
#define MAX_BUFFER_SIZE 4096
|
||||
#define MAX_FDS 28
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -72,6 +72,11 @@ pinos_connection_add_fd (PinosConnection *conn,
|
|||
}
|
||||
|
||||
index = conn->out.n_fds;
|
||||
if (index >= MAX_FDS) {
|
||||
pinos_log_error ("connection %p: too many fds", conn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
conn->out.fds[index] = fd;
|
||||
conn->out.n_fds++;
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ write_pod (SpaPODBuilder *b, uint32_t ref, const void *data, uint32_t size)
|
|||
ref = b->offset;
|
||||
|
||||
if (b->size <= b->offset) {
|
||||
b->size = SPA_ROUND_UP_N (b->offset + size, 512);
|
||||
b->size = SPA_ROUND_UP_N (b->offset + size, 4096);
|
||||
b->data = pinos_connection_begin_write (((Builder*)b)->connection, b->size);
|
||||
}
|
||||
memcpy (b->data + ref, data, size);
|
||||
|
|
|
|||
|
|
@ -664,7 +664,7 @@ client_node_done (void *object,
|
|||
PinosProxy *proxy = object;
|
||||
PinosStream *stream = proxy->user_data;
|
||||
|
||||
pinos_log_warn ("create client node done");
|
||||
pinos_log_info ("strean %p: create client node done with fd %d", stream, datafd);
|
||||
handle_socket (stream, datafd);
|
||||
do_node_init (stream);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ write_pod (SpaPODBuilder *b, uint32_t ref, const void *data, uint32_t size)
|
|||
ref = b->offset;
|
||||
|
||||
if (b->size <= b->offset) {
|
||||
b->size = SPA_ROUND_UP_N (b->offset + size, 512);
|
||||
b->size = SPA_ROUND_UP_N (b->offset + size, 4096);
|
||||
b->data = pinos_connection_begin_write (((Builder*)b)->connection, b->size);
|
||||
}
|
||||
memcpy (b->data + ref, data, size);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue