Skip to content

Commit

Permalink
get_shadow_line: Correctly detect socket() failure
Browse files Browse the repository at this point in the history
  • Loading branch information
donald committed May 18, 2021
1 parent 664fa17 commit 21249d8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion get_shadow_line.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static int get_shadow_line(char *user, char **line) {
if (SSL_CTX_load_verify_locations(ssl_ctx, "/etc/mxshadow.cert.pem", NULL) == 0) { psslerror("SSL_CTX_load_verify_locations"); return -1; }

int sock = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
if (sock == 0) { COMMON_LOG(LOG_ERR, "socket: %m"); return -1; }
if (sock == -1) { COMMON_LOG(LOG_ERR, "socket: %m"); return -1; }

status = connect_with_timeout(sock, (struct sockaddr *)&sockaddr, sizeof(sockaddr), TIMEOUT);
if (status == -1) { COMMON_LOG(LOG_ERR, "connect: %m"); return -1; }
Expand Down

0 comments on commit 21249d8

Please sign in to comment.