rfsim: add a check on 'sock'

It is very possible that the operating system returns a file
descriptor bigger than the size of bridge->buf (MAX_FD_RFSIMU, which
is 250 as of now). As a minimum, let's fail if the socket file
descriptor is out of bounds.

A proper solution may be implemented later, if needed.
This commit is contained in:
Cedric Roux
2024-08-29 14:59:51 +02:00
parent 46a1d2a621
commit 42539b0bec
+2
View File
@@ -182,6 +182,8 @@ typedef struct {
static int allocCirBuf(rfsimulator_state_t *bridge, int sock)
{
/* TODO: cleanup code so that this AssertFatal becomes useless */
AssertFatal(sock >= 0 && sock < sizeofArray(bridge->buf), "socket %d is not in range\n", sock);
buffer_t *ptr=&bridge->buf[sock];
ptr->circularBuf = calloc(1, sampleToByte(CirSize, 1));
if (ptr->circularBuf == NULL) {