Skip to content

Commit

Permalink
Update strlcpy from musl to 1.2.0 to fix #7279 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
kripken committed Apr 13, 2020
1 parent 84a3d51 commit da40f75
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions system/lib/libc/musl/src/string/strlcpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <string.h>
#include <stdint.h>
#include <limits.h>
#include "libc.h"

#define ALIGN (sizeof(size_t)-1)
#define ONES ((size_t)-1/UCHAR_MAX)
Expand All @@ -13,9 +12,11 @@ size_t strlcpy(char *d, const char *s, size_t n)
{
char *d0 = d;
size_t *wd;
const size_t *ws;

if (!n--) goto finish;
#ifdef __GNUC__
typedef size_t __attribute__((__may_alias__)) word;
const word *ws;
if (((uintptr_t)s & ALIGN) == ((uintptr_t)d & ALIGN)) {
for (; ((uintptr_t)s & ALIGN) && n && (*d=*s); n--, s++, d++);
if (n && *s) {
Expand All @@ -25,6 +26,7 @@ size_t strlcpy(char *d, const char *s, size_t n)
d=(void *)wd; s=(const void *)ws;
}
}
#endif
for (; n && (*d=*s); n--, s++, d++);
*d = 0;
finish:
Expand Down

0 comments on commit da40f75

Please sign in to comment.