mailing list of musl libc
 help / color / mirror / code / Atom feed
bc2644132c11991bfed24e1ba526af2cf0e4d5ef blob 795 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
 
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include "word.h"

/**
 * strlcpy - Word sized bsd strlcpy.
 * @d: Destination
 * @s: Source
 * @n: Max @s
 */
size_t strlcpy(char *d, const char *s, size_t n)
{
	char *z = d;
	size_t *wd;
	const size_t *ws;

	/* A byte for nul */
	if (!n--) goto terminate;

	if ((uintptr_t)d % sizeof(size_t) != (uintptr_t)s % sizeof(size_t))
		goto misaligned;

	for (; (uintptr_t)s % sizeof(size_t); *d++ = *s++, n--)
		if (!*s || !n) goto terminate;

	for (wd = (size_t *)d, ws= (const size_t *)s
	     ; !word_has_zero(*ws) && n >= sizeof(size_t)
	     ; *wd = *ws, wd++, ws++, n -= sizeof(size_t))

	d = (char *)wd;
	s = (const char *)ws;

misaligned:
	for (; (*d = *s) && n; d++, s++, n--);
terminate:
	*d = '\0';

	return d - z + strlen(s);
}
debug log:

solving bc26441 ...
found bc26441 in https://inbox.vuxu.org/musl/1359936735-31915-5-git-send-email-nwmcsween@gmail.com/
found 4d3ff92 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 4d3ff92a8d79997c139b8a0eaaaefe54e5b7a2e6	src/string/strlcpy.c

applying [1/1] https://inbox.vuxu.org/musl/1359936735-31915-5-git-send-email-nwmcsween@gmail.com/
diff --git a/src/string/strlcpy.c b/src/string/strlcpy.c
index 4d3ff92..bc26441 100644

Checking patch src/string/strlcpy.c...
Applied patch src/string/strlcpy.c cleanly.

index at:
100644 bc2644132c11991bfed24e1ba526af2cf0e4d5ef	src/string/strlcpy.c

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).