Skip to content

Commit 5481fdf

Browse files
committed
Check return of value of send
1 parent 90e3f33 commit 5481fdf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/simple_http.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ http_get(const int sockfd, const char *req)
7575
}
7676

7777
debug(LOG_DEBUG, "Sending HTTP request to auth server: [%s]\n", req);
78-
send(sockfd, req, reqlen, 0);
78+
numbytes = send(sockfd, req, reqlen, 0);
79+
// Cast numbytes to unsigned type because < 0 is already checked
80+
if (numbytes < 0 || (size_t) numbytes != reqlen) {
81+
debug(LOG_ERR, "An error occurred while writing to server: %s", strerror(errno));
82+
goto error;
83+
}
7984

8085
debug(LOG_DEBUG, "Reading response");
8186
done = 0;

0 commit comments

Comments
 (0)