From 079549cbd2663fb08d8ad265069d72c45e399c4b Mon Sep 17 00:00:00 2001 From: Themaister Date: Mon, 11 Apr 2011 21:28:03 +0200 Subject: [PATCH] Fix an edge case with strlcat(). --- strl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/strl.c b/strl.c index 13600bda40..25e7fd2fb7 100644 --- a/strl.c +++ b/strl.c @@ -41,7 +41,12 @@ size_t strlcat(char *dest, const char *source, size_t size) { size_t len = strlen(dest); dest += len; - size -= len; + + if (len > size) + size = 0; + else + size -= len; + return len + strlcpy(dest, source, size); } #endif