build: constify memchr()/strchr()/etc result variables

And a few variables around.

There remain cases where the accepted pointer is const, yet the returned
pointer is written to.

Partly addressing (glibc 2.43):
```
* For ISO C23, the functions bsearch, memchr, strchr, strpbrk, strrchr,
  strstr, wcschr, wcspbrk, wcsrchr, wcsstr and wmemchr that return
  pointers into their input arrays now have definitions as macros that
  return a pointer to a const-qualified type when the input argument is
  a pointer to a const-qualified type.
```
Ref: https://lists.gnu.org/archive/html/info-gnu/2026-01/msg00005.html

Reported-by: Rudi Heitbaum
Ref: #20420

Closes #20421
This commit is contained in:
Viktor Szakats 2026-01-25 03:26:03 +01:00
parent 7dc60bdb90
commit 0e2507a3c6
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
22 changed files with 54 additions and 53 deletions

View file

@ -3829,7 +3829,7 @@ static CURLcode verify_header(struct Curl_easy *data,
const char *hd, size_t hdlen)
{
struct SingleRequest *k = &data->req;
char *ptr = memchr(hd, 0x00, hdlen);
const char *ptr = memchr(hd, 0x00, hdlen);
if(ptr) {
/* this is bad, bail out */
failf(data, "Nul byte in header");
@ -4369,7 +4369,7 @@ static CURLcode http_parse_headers(struct Curl_easy *data,
struct connectdata *conn = data->conn;
CURLcode result = CURLE_OK;
struct SingleRequest *k = &data->req;
char *end_ptr;
const char *end_ptr;
bool leftover_body = FALSE;
/* we have bytes for the next header, make sure it is not a folded header