mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
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:
parent
3c28be8255
commit
81d4d5dd2b
2 changed files with 3 additions and 14 deletions
|
@ -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).
|
* Returns strlen(src) + MIN(siz, strlen(initial dst).
|
||||||
* If retval >= siz, truncation occurred.
|
* If retval >= siz, truncation occurred.
|
||||||
*/
|
*/
|
||||||
PHPAPI size_t php_strlcat(dst, src, siz)
|
PHPAPI size_t php_strlcat(char *dst, const char *src, size_t siz)
|
||||||
char *dst;
|
|
||||||
const char *src;
|
|
||||||
size_t siz;
|
|
||||||
{
|
{
|
||||||
const char *d = dst;
|
const char *d = dst;
|
||||||
const char *s = src;
|
const char *s = src;
|
||||||
|
|
|
@ -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).
|
* will be copied. Always NUL terminates (unless siz == 0).
|
||||||
* Returns strlen(src); if retval >= siz, truncation occurred.
|
* Returns strlen(src); if retval >= siz, truncation occurred.
|
||||||
*/
|
*/
|
||||||
PHPAPI size_t php_strlcpy(dst, src, siz)
|
PHPAPI size_t php_strlcpy(char *dst, const char *src, size_t siz)
|
||||||
char *dst;
|
|
||||||
const char *src;
|
|
||||||
size_t siz;
|
|
||||||
{
|
{
|
||||||
const char *s = src;
|
const char *s = src;
|
||||||
size_t n = siz;
|
size_t n = siz;
|
||||||
|
@ -83,12 +80,7 @@ PHPAPI size_t php_strlcpy(dst, src, siz)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
return(src - s - 1);
|
||||||
* 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !HAVE_STRLCPY */
|
#endif /* !HAVE_STRLCPY */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue