aboutsummaryrefslogtreecommitdiffstats
path: root/src/wps
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2015-04-28 14:30:08 (GMT)
committerJouni Malinen <j@w1.fi>2015-05-03 15:26:50 (GMT)
commit8640cf7f8f478d27901acf84d3e52a55c7dde5f7 (patch)
tree3b43b61406c34336b2f25e4219e78e84f9d5dd92 /src/wps
parent1bd0d578a943c1d2dcccb97bb3ad5ce26c770e18 (diff)
downloadhostap-8640cf7f8f478d27901acf84d3e52a55c7dde5f7.zip
hostap-8640cf7f8f478d27901acf84d3e52a55c7dde5f7.tar.gz
hostap-8640cf7f8f478d27901acf84d3e52a55c7dde5f7.tar.bz2
WPS: Add more debug prints to httpread
These can be helpful when debugging HTTP error cases. Signed-off-by: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'src/wps')
-rw-r--r--src/wps/httpread.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/wps/httpread.c b/src/wps/httpread.c
index bb213d4..180b572 100644
--- a/src/wps/httpread.c
+++ b/src/wps/httpread.c
@@ -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 */