]> git.ipfire.org Git - thirdparty/curl.git/commit
strdup: don't allow Curl_strndup to read past a null terminator
authorJay Satiro <raysatiro@yahoo.com>
Thu, 2 Nov 2023 22:56:06 +0000 (18:56 -0400)
committerJay Satiro <raysatiro@yahoo.com>
Fri, 3 Nov 2023 03:44:46 +0000 (23:44 -0400)
commit4855debd8a2c1cbd0b0dbbb8319b1743c4644873
treec4eb7bf625b4f580cb63a327c959eef040c5dfad
parentd3b3ba35a5c4f862df2aa3e12de983e5457b429a
strdup: don't allow Curl_strndup to read past a null terminator

- Use malloc + strncpy instead of Curl_memdup to dupe the string before
  null terminating it.

Prior to this change if Curl_strndup was passed a length longer than
the allocated string then it could copy out of bounds.

This change is for posterity. Curl_strndup was added in the parent
commit and currently none of the calls to it pass a length that would
cause it to read past the allocated length of the input.

Follow-up to d3b3ba35.

Closes https://github.com/curl/curl/pull/12254
lib/strdup.c