mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-25 08:48:31 -05:00
WPS: Add more debug prints to httpread
These can be helpful when debugging HTTP error cases. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
1bd0d578a9
commit
8640cf7f8f
@ -380,8 +380,11 @@ static void httpread_read_handler(int sd, void *eloop_ctx, void *sock_ctx)
|
||||
*/
|
||||
wpa_printf(MSG_DEBUG, "httpread: Trying to read more data(%p)", h);
|
||||
nread = read(h->sd, readbuf, sizeof(readbuf));
|
||||
if (nread < 0)
|
||||
if (nread < 0) {
|
||||
wpa_printf(MSG_DEBUG, "httpread failed: %s", strerror(errno));
|
||||
goto bad;
|
||||
}
|
||||
wpa_hexdump_ascii(MSG_MSGDUMP, "httpread - read", readbuf, nread);
|
||||
if (nread == 0) {
|
||||
/* end of transmission... this may be normal
|
||||
* or may be an error... in some cases we can't
|
||||
@ -424,6 +427,8 @@ static void httpread_read_handler(int sd, void *eloop_ctx, void *sock_ctx)
|
||||
if (nread == 0)
|
||||
goto get_more;
|
||||
if (h->hdr_nbytes == HTTPREAD_HEADER_MAX_SIZE) {
|
||||
wpa_printf(MSG_DEBUG,
|
||||
"httpread: Too long header");
|
||||
goto bad;
|
||||
}
|
||||
*hbp++ = *rbp++;
|
||||
@ -485,8 +490,12 @@ static void httpread_read_handler(int sd, void *eloop_ctx, void *sock_ctx)
|
||||
char *new_body;
|
||||
int new_alloc_nbytes;
|
||||
|
||||
if (h->body_nbytes >= h->max_bytes)
|
||||
if (h->body_nbytes >= h->max_bytes) {
|
||||
wpa_printf(MSG_DEBUG,
|
||||
"httpread: body_nbytes=%d >= max_bytes=%d",
|
||||
h->body_nbytes, h->max_bytes);
|
||||
goto bad;
|
||||
}
|
||||
new_alloc_nbytes = h->body_alloc_nbytes +
|
||||
HTTPREAD_BODYBUF_DELTA;
|
||||
/* For content-length case, the first time
|
||||
@ -504,8 +513,12 @@ static void httpread_read_handler(int sd, void *eloop_ctx, void *sock_ctx)
|
||||
goto bad;
|
||||
}
|
||||
if ((new_body = os_realloc(h->body, new_alloc_nbytes))
|
||||
== NULL)
|
||||
== NULL) {
|
||||
wpa_printf(MSG_DEBUG,
|
||||
"httpread: Failed to reallocate buffer (len=%d)",
|
||||
new_alloc_nbytes);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
h->body = new_body;
|
||||
h->body_alloc_nbytes = new_alloc_nbytes;
|
||||
@ -524,8 +537,11 @@ static void httpread_read_handler(int sd, void *eloop_ctx, void *sock_ctx)
|
||||
/* hdr line consists solely
|
||||
* of a hex numeral and CFLF
|
||||
*/
|
||||
if (!isxdigit(*cbp))
|
||||
if (!isxdigit(*cbp)) {
|
||||
wpa_printf(MSG_DEBUG,
|
||||
"httpread: Unexpected chunk header value (not a hex digit)");
|
||||
goto bad;
|
||||
}
|
||||
h->chunk_size = strtoul(cbp, NULL, 16);
|
||||
if (h->chunk_size < 0 ||
|
||||
h->chunk_size > h->max_bytes) {
|
||||
@ -563,8 +579,11 @@ static void httpread_read_handler(int sd, void *eloop_ctx, void *sock_ctx)
|
||||
*/
|
||||
if (bbp[-1] == '\n' &&
|
||||
bbp[-2] == '\r') {
|
||||
} else
|
||||
} else {
|
||||
wpa_printf(MSG_DEBUG,
|
||||
"httpread: Invalid chunk end");
|
||||
goto bad;
|
||||
}
|
||||
h->body_nbytes -= 2;
|
||||
bbp -= 2;
|
||||
h->chunk_start = h->body_nbytes;
|
||||
@ -668,11 +687,14 @@ bad:
|
||||
return;
|
||||
|
||||
get_more:
|
||||
wpa_printf(MSG_DEBUG, "httpread: get more (%p)", h);
|
||||
return;
|
||||
|
||||
got_file:
|
||||
wpa_printf(MSG_DEBUG, "httpread got file %d bytes type %d",
|
||||
h->body_nbytes, h->hdr_type);
|
||||
wpa_hexdump_ascii(MSG_MSGDUMP, "httpread: body",
|
||||
h->body, h->body_nbytes);
|
||||
/* Null terminate for convenience of some applications */
|
||||
if (h->body)
|
||||
h->body[h->body_nbytes] = 0; /* null terminate */
|
||||
|
Loading…
Reference in New Issue
Block a user