wdvi

network DVI viewer
Log | Files | Refs

commit eb6d52754dc28ac7b2cef1221e00d11fcf6459b8
parent a3f09e1758eccf33c0409e983fca758b02ab8070
Author: Kyle Milz <krwmilz@gmail.com>
Date:   Thu, 16 Sep 2021 01:30:55 +0000

two small fixes for http

- glibc sscanf() doesn't like the character class [^\0]; use [^\n] instead
- fix bug in finding document while parsing url; strsep() misuse problem

Diffstat:
Mhttp.c | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/http.c b/http.c @@ -89,8 +89,9 @@ parse_url(const char dest_url[]) else sep_url = reset; - /* If found set document path */ - if (strsep(&sep_url, "/")) + strsep(&sep_url, "/"); + if (sep_url != NULL) + /* / was found, set document path */ url->document = sep_url; return url; @@ -322,7 +323,7 @@ parse_headers(char *hdr, int hdr_len) goto free_res; /* First line of response is 'HTTP/1.1 200 OK' for example. */ - if (sscanf(line, "%15s %i %31[^\0]", res->ver, &res->stat, + if (sscanf(line, "%15s %i %31[^\n]", res->ver, &res->stat, res->stat_text) != 3) goto free_res;