Skip to content
Snippets Groups Projects
Commit ed6b3961 authored by Andy Green's avatar Andy Green
Browse files

test server http dont print junk if string too long

parent 1f8ec7c8
No related branches found
No related tags found
No related merge requests found
...@@ -62,7 +62,7 @@ struct serveable { ...@@ -62,7 +62,7 @@ struct serveable {
void void
dump_handshake_info(struct lws *wsi) dump_handshake_info(struct lws *wsi)
{ {
int n = 0; int n = 0, len;
char buf[256]; char buf[256];
const unsigned char *c; const unsigned char *c;
...@@ -73,12 +73,14 @@ dump_handshake_info(struct lws *wsi) ...@@ -73,12 +73,14 @@ dump_handshake_info(struct lws *wsi)
continue; continue;
} }
if (!lws_hdr_total_length(wsi, n)) { len = lws_hdr_total_length(wsi, n);
if (!len || len > sizeof(buf) - 1) {
n++; n++;
continue; continue;
} }
lws_hdr_copy(wsi, buf, sizeof buf, n); lws_hdr_copy(wsi, buf, sizeof buf, n);
buf[sizeof(buf) - 1] = '\0';
fprintf(stderr, " %s = %s\n", (char *)c, buf); fprintf(stderr, " %s = %s\n", (char *)c, buf);
n++; n++;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment