Skip to content

Commit

Permalink
libhfuzz: fix strlcat wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
robertswiecki committed Nov 24, 2023
1 parent 88709ce commit 1912660
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions libhfuzz/memorycmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,15 @@ static inline size_t HF_strlcpy(char* dest, const char* src, size_t sz, uintptr_
}

static inline size_t HF_strlcat(char* dest, const char* src, size_t sz, uintptr_t addr) {
size_t len = __builtin_strlen(dest);
return HF_strlcpy(dest + len, src, sz, addr);
size_t dstlen = __builtin_strlen(dest);

if (dstlen >= sz) {
return dstlen + __builtin_strlen(src);
}

size_t left = sz - dstlen;

return dstlen + HF_strlcpy(dest + dstlen, src, left, addr);
}

/* Define a weak function x, as well as __wrap_x pointing to x */
Expand Down

0 comments on commit 1912660

Please sign in to comment.