Skip to content

Commit

Permalink
improve logging when the status line is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkr committed Jul 9, 2022
1 parent 064fd5b commit c452d34
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,4 @@ additional documentation and more details are available in `man gplaces`. type `
## Statistic
Language|files|blank|comment|code
:-------|-------:|-------:|-------:|-------:
C|1|236|58|1083
C|1|236|58|1084
3 changes: 2 additions & 1 deletion gplaces.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,8 @@ static int do_download(Selector *sel, SSL_CTX *ctx, const char *crtpath, const c
}

for (total = 0; total < (int)sizeof(data) - 1 && (total < 4 || (data[total - 2] != '\r' && data[total - 1] != '\n')) && (received = SSL_read(ssl, &data[total], 1)) > 0; ++total);
if (total < 4 || data[0] < '1' || data[0] > '6' || data[1] < '0' || data[1] > '9' || (total > 4 && data[2] != ' ') || data[total - 2] != '\r' || data[total - 1] != '\n' || (received < 0 && ssl_error(sel, ssl, received))) goto fail;
if (received < 0 && ssl_error(sel, ssl, received)) goto fail;
else if (total < 4 || data[0] < '1' || data[0] > '6' || data[1] < '0' || data[1] > '9' || (total > 4 && data[2] != ' ') || data[total - 2] != '\r' || data[total - 1] != '\n') { error(0, "failed to download `%s`: invalid status line", sel->url); goto fail; }
data[total] = '\0';

crlf = &data[total - 2];
Expand Down

0 comments on commit c452d34

Please sign in to comment.