diff options
| author | Nakidai <nakidai@disroot.org> | 2024-12-09 02:49:12 +0300 |
|---|---|---|
| committer | Nakidai <nakidai@disroot.org> | 2024-12-09 02:49:12 +0300 |
| commit | 62bc1d76c35e3c2db1c0d6f20b941e078373fa01 (patch) | |
| tree | 2c6521225d3ad8811f5e3fed4a989d253a2962f3 | |
| parent | c296cef100e8bbe39fff1f7a4316ecbe961787d7 (diff) | |
| download | libhttpc-62bc1d76c35e3c2db1c0d6f20b941e078373fa01.tar.gz libhttpc-62bc1d76c35e3c2db1c0d6f20b941e078373fa01.zip | |
Add checks for LibHTTPC_loadRequest
From now function will return NULL if it couldn't find end
| -rw-r--r-- | src/request.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/request.c b/src/request.c index fd868f8..644cd4b 100644 --- a/src/request.c +++ b/src/request.c @@ -35,18 +35,26 @@ struct LibHTTPC_Request *LibHTTPC_loadRequest(struct LibHTTPC_Request *request_b request_buf->method = request_buf->buf = buf; next = strchr(request_buf->method, ' '); + if (!next) + return NULL; *next = '\0'; request_buf->uri = next + 1; next = strchr(request_buf->uri, ' '); + if (!next) + return NULL; *next = '\0'; request_buf->version = next + 1; next = strstr(request_buf->version, "\r\n"); + if (!next) + return NULL; *next++ = '\0'; for (size_t i = 0; (next = strstr(next, "\r\n")); ++next, ++i) { + if (!next) + return NULL; *next = '\0'; next += 2; @@ -67,6 +75,8 @@ struct LibHTTPC_Request *LibHTTPC_loadRequest(struct LibHTTPC_Request *request_b { request_buf->headers[i].name = next; next = strchr(next, ':'); + if (!next) + return NULL; *next++ = '\0'; request_buf->headers[i].value = next; } |