Skip to content

Commit

Permalink
Fix Coverity defect
Browse files Browse the repository at this point in the history
CID 456637:  Error handling issues  (CHECKED_RETURN)
Calling "setsockopt(new_socket, IPPROTO_TCP, 1, &flag, 4U)" without
checking return value. This library function may fail and return an
error code.
  • Loading branch information
DimitriPapadopoulos committed Feb 10, 2025
1 parent ebc8cdd commit 8a75d6e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/http_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ static int process_request(int new_socket, char *id)

int flag = 1;

setsockopt(new_socket, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(int));
if (setsockopt(new_socket, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag))) {
log_error("Failed to set socket options\n");
return -1;
}

// Read the request
char request[1024];
Expand Down

0 comments on commit 8a75d6e

Please sign in to comment.