strlcpy/strlcat update to last openbsd version.

CVS date not changed as in fact the actual version is related to an earier date
 in reality.
They ditched the `uintptr_t`cast finally. While at it
updating the C style definitions.

Closes GH-8389.
This commit is contained in:
David Carlier 2022-04-17 11:08:09 +01:00 committed by Christoph M. Becker
parent 3c28be8255
commit 81d4d5dd2b
No known key found for this signature in database
GPG Key ID: D66C9593118BCCB6
2 changed files with 3 additions and 14 deletions

View File

@ -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;

View File

@ -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;
@ -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 */