Skip to content

strlcpy update to last openbsd version. #8389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions main/strlcat.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ static const char *rcsid = "$OpenBSD: strlcat.c,v 1.17 2016/10/14 18:19:04 dtuck
* Returns strlen(src) + MIN(siz, strlen(initial dst).
* If retval >= siz, truncation occurred.
*/
PHPAPI size_t php_strlcat(dst, src, siz)
char *dst;
const char *src;
size_t siz;
PHPAPI size_t php_strlcat(char *dst, const char *src, size_t siz)
{
const char *d = dst;
const char *s = src;
Expand Down
12 changes: 2 additions & 10 deletions main/strlcpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ static const char *rcsid = "$OpenBSD: strlcpy.c,v 1.15 2016/10/16 17:37:39 dtuck
* will be copied. Always NUL terminates (unless siz == 0).
* Returns strlen(src); if retval >= siz, truncation occurred.
*/
PHPAPI size_t php_strlcpy(dst, src, siz)
char *dst;
const char *src;
size_t siz;
PHPAPI size_t php_strlcpy(char *dst, const char *src, size_t siz)
{
const char *s = src;
size_t n = siz;
Expand All @@ -83,12 +80,7 @@ PHPAPI size_t php_strlcpy(dst, src, siz)
;
}

/*
* Cast pointers to unsigned type before calculation, to avoid signed
* overflow when the string ends where the MSB has changed.
* Return value does not include NUL.
*/
return((uintptr_t)src - (uintptr_t)s - 1);
return(src - s - 1);
}

#endif /* !HAVE_STRLCPY */