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:
@@ -182,6 +182,8 @@ typedef struct {
|
|||||||
|
|
||||||
static int allocCirBuf(rfsimulator_state_t *bridge, int sock)
|
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];
|
buffer_t *ptr=&bridge->buf[sock];
|
||||||
ptr->circularBuf = calloc(1, sampleToByte(CirSize, 1));
|
ptr->circularBuf = calloc(1, sampleToByte(CirSize, 1));
|
||||||
if (ptr->circularBuf == NULL) {
|
if (ptr->circularBuf == NULL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user