Skip to content

Commit 19ad00a

Browse files
committed
Check return of send()
1 parent 270fb5c commit 19ad00a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/simple_http.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,14 @@ 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+
if (numbytes <= 0) {
80+
debug(LOG_ERR, "send failed: %s", strerror(errno));
81+
goto error;
82+
} else if ((size_t) numbytes != reqlen) {
83+
debug(LOG_ERR, "send failed: only %d bytes out of %d bytes sent!", numbytes, reqlen);
84+
goto error;
85+
}
7986

8087
debug(LOG_DEBUG, "Reading response");
8188
done = 0;

0 commit comments

Comments
 (0)