Skip to content

Commit

Permalink
ipc: decrement backlog and check for null pointers in accept()
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Sep 7, 2024
1 parent e7a5a25 commit d80cb8a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ipc/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,15 @@ int accept(Thread *t, int sd, struct sockaddr *addr, socklen_t *len) {
memcpy(&self->address, &listener->address, sizeof(struct sockaddr));
self->type = listener->type;
self->protocol = listener->protocol;
self->process = listener->process;

// and assign the peer address
self->peer = listener->backlog[0]; // TODO: is this always FIFO?
memmove(&listener->backlog[0], &listener->backlog[1], (listener->backlogMax - 1) * sizeof(SocketDescriptor *));
listener->backlogCount--;

socketRelease();
return connectedSocket;

if(!self->peer) return -ECONNABORTED;
else return connectedSocket;
}

0 comments on commit d80cb8a

Please sign in to comment.