diff options
-rw-r--r-- | firmware/common/strlcat.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/firmware/common/strlcat.c b/firmware/common/strlcat.c index 783ea4daba..f1f0031f06 100644 --- a/firmware/common/strlcat.c +++ b/firmware/common/strlcat.c | |||
@@ -16,7 +16,7 @@ | |||
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <string.h> | 19 | #include "string-extra.h" |
20 | 20 | ||
21 | /* | 21 | /* |
22 | * Appends src to string dst of size siz (unlike strncat, siz is the | 22 | * Appends src to string dst of size siz (unlike strncat, siz is the |
@@ -29,9 +29,7 @@ size_t | |||
29 | strlcat(char *dst, const char *src, size_t siz) | 29 | strlcat(char *dst, const char *src, size_t siz) |
30 | { | 30 | { |
31 | char *d = dst; | 31 | char *d = dst; |
32 | const char *s = src; | 32 | size_t dlen, n = siz; |
33 | size_t n = siz; | ||
34 | size_t dlen; | ||
35 | 33 | ||
36 | /* Find the end of dst and adjust bytes left but don't go past end */ | 34 | /* Find the end of dst and adjust bytes left but don't go past end */ |
37 | while (n-- != 0 && *d != '\0') | 35 | while (n-- != 0 && *d != '\0') |
@@ -39,17 +37,6 @@ strlcat(char *dst, const char *src, size_t siz) | |||
39 | dlen = d - dst; | 37 | dlen = d - dst; |
40 | n = siz - dlen; | 38 | n = siz - dlen; |
41 | 39 | ||
42 | if (n == 0) | 40 | return strlcpy(dst + dlen, src, n) + dlen; |
43 | return(dlen + strlen(s)); | ||
44 | while (*s != '\0') { | ||
45 | if (n != 1) { | ||
46 | *d++ = *s; | ||
47 | n--; | ||
48 | } | ||
49 | s++; | ||
50 | } | ||
51 | *d = '\0'; | ||
52 | |||
53 | return(dlen + (s - src)); /* count does not include NUL */ | ||
54 | } | 41 | } |
55 | 42 | ||