commit 8ef0c002c20ab8608cbf3c72a44f3a8e4f2c26df from: Sergey Bronnikov date: Mon Oct 07 12:39:31 2024 UTC httpc: replace ibuf_alloc with xibuf_alloc There is no check for NULL for a value returned by `ibuf_alloc`, the NULL will be passed to `memcpy()` if the aforementioned function will return a NULL. The patch fixes that by replacing `ibuf_alloc` with macros `xibuf_alloc` that never return NULL. Found by Svace. NO_CHANGELOG=codehealth NO_DOC=codehealth NO_TEST=codehealth (cherry picked from commit b4ee146fde6e418aed590ac6054cff75c2a59626) commit - d615f3f74f9c9a36029b39e01dc6e9a1495442d5 commit + 8ef0c002c20ab8608cbf3c72a44f3a8e4f2c26df blob - 30327afd4f9a0af195ce47af13c5d063c6b914d7 blob + dd2af53e5721d9624025bf9134a763541c7bbc33 --- src/httpc.c +++ src/httpc.c @@ -578,7 +578,7 @@ httpc_request_io_read(struct httpc_request *req, char if (recv_len > remain) { const size_t tocopy = recv_len - remain; - char *ptr = ibuf_alloc(&req->io_recv, tocopy); + char *ptr = xibuf_alloc(&req->io_recv, tocopy); memcpy(ptr, recv + remain, tocopy); } @@ -626,7 +626,7 @@ httpc_request_io_write(struct httpc_request *req, cons if (len > 0) { ibuf_reset(&req->send); - char *buf = ibuf_alloc(&req->send, len); + char *buf = xibuf_alloc(&req->send, len); memcpy(buf, ptr, len); } else { req->io_send_closed = true;