Skip to content

Commit 3182c41

Browse files
Fix function call error and NULL path send out
Check pointer to avoid NULL pointer input to strlen() Auto replace NULL path to "/" (As Firefox`s implementation)
1 parent 12e2b53 commit 3182c41

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

htstress.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,12 @@ int main(int argc, char *argv[])
487487
/* prepare request buffer */
488488
if (!host)
489489
host = node;
490-
outbufsize = strlen(rq) + sizeof(HTTP_REQUEST_FMT) + strlen(host);
490+
outbufsize = sizeof(HTTP_REQUEST_FMT) + strlen(host);
491+
outbufsize += rq ? strlen(rq) : 1;
492+
491493
outbuf = malloc(outbufsize);
492-
outbufsize = snprintf(outbuf, outbufsize, HTTP_REQUEST_FMT, rq, host);
494+
outbufsize = rq ? snprintf(outbuf, outbufsize, HTTP_REQUEST_FMT, rq, host)
495+
: snprintf(outbuf, outbufsize, HTTP_REQUEST_FMT, "/", host);
493496

494497
ticks = max_requests / 10;
495498

0 commit comments

Comments
 (0)