Loading lib/strequal.c +23 −8 Original line number Original line Diff line number Diff line Loading @@ -77,18 +77,33 @@ int Curl_strnequal(const char *first, const char *second, size_t max) * For strlcat() that means the initial length of dst plus the length of * For strlcat() that means the initial length of dst plus the length of * src. While this may seem somewhat confusing it was done to make trunca- * src. While this may seem somewhat confusing it was done to make trunca- * tion detection simple. * tion detection simple. * * */ */ size_t strlcat(char *dst, const char *src, size_t size) size_t strlcat(char *dst, const char *src, size_t size) { { size_t len = strlen(dst); char *d = dst; size_t orglen = len; const char *s = src; int index=0; size_t n = siz; size_t dlen; while(src[index] && (len < (size-1)) ) { /* Find the end of dst and adjust bytes left but don't go past end */ dst[len++] = src[index++]; while (n-- != 0 && *d != '\0') d++; dlen = d - dst; n = siz - dlen; if (n == 0) return(dlen + strlen(s)); while (*s != '\0') { if (n != 1) { *d++ = *s; n--; } s++; } } dst[len]=0; *d = '\0'; return orglen + strlen(src); return(dlen + (s - src)); /* count does not include NUL */ } } #endif #endif Loading
lib/strequal.c +23 −8 Original line number Original line Diff line number Diff line Loading @@ -77,18 +77,33 @@ int Curl_strnequal(const char *first, const char *second, size_t max) * For strlcat() that means the initial length of dst plus the length of * For strlcat() that means the initial length of dst plus the length of * src. While this may seem somewhat confusing it was done to make trunca- * src. While this may seem somewhat confusing it was done to make trunca- * tion detection simple. * tion detection simple. * * */ */ size_t strlcat(char *dst, const char *src, size_t size) size_t strlcat(char *dst, const char *src, size_t size) { { size_t len = strlen(dst); char *d = dst; size_t orglen = len; const char *s = src; int index=0; size_t n = siz; size_t dlen; while(src[index] && (len < (size-1)) ) { /* Find the end of dst and adjust bytes left but don't go past end */ dst[len++] = src[index++]; while (n-- != 0 && *d != '\0') d++; dlen = d - dst; n = siz - dlen; if (n == 0) return(dlen + strlen(s)); while (*s != '\0') { if (n != 1) { *d++ = *s; n--; } s++; } } dst[len]=0; *d = '\0'; return orglen + strlen(src); return(dlen + (s - src)); /* count does not include NUL */ } } #endif #endif