Fixed 1-byte overflow in safe_append
This commit is contained in:
parent
577dfd9e1a
commit
3820ba88dc
|
@ -66,10 +66,10 @@ void urlencode(const char *str, char *result) {
|
|||
char* safe_append(char *target, size_t *targetsize, const char *src) {
|
||||
size_t targetlen = strlen(target);
|
||||
size_t srclen = strlen(src);
|
||||
size_t newsize = targetlen + 2*srclen + 1;
|
||||
size_t newsize = 2*targetlen + srclen + 1;
|
||||
|
||||
// check if reallocation is necessary
|
||||
if((targetlen + srclen) > *targetsize) {
|
||||
if((targetlen + srclen) >= *targetsize) {
|
||||
LOG(LVL_DEBUG, "safe_append: reallocating target string: %lu -> %lu characters", *targetsize, newsize);
|
||||
|
||||
target = realloc(target, newsize * sizeof(char));
|
||||
|
|
Loading…
Reference in a new issue