It would try to read longer than the provided string and crash.
Follow-up to
ff74cef5d4a0cf60106517a1c7384
Reported-by: calvin2021y on github
Fixes #12578
Closes #12579
{
#ifndef CURL_DISABLE_VERBOSE_STRINGS
const char *p;
+ size_t alen;
#endif
- /* 41 bytes is the longest error string */
- DEBUGASSERT(len > 41);
- if(!len || len < 41)
+ if(!len)
return NULL;
*buf = '\0';
default:
return NULL;
}
- memcpy(buf, p, len - 1);
- buf[len - 1] = '\0';
+ alen = strlen(p);
+ if(alen < len)
+ strcpy(buf, p);
return buf;
#endif
}