Skip to content

Commit 81d4d5d

Browse files
devnexencmb69
authored andcommitted
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.
1 parent 3c28be8 commit 81d4d5d

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

main/strlcat.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@ static const char *rcsid = "$OpenBSD: strlcat.c,v 1.17 2016/10/14 18:19:04 dtuck
6161
* Returns strlen(src) + MIN(siz, strlen(initial dst).
6262
* If retval >= siz, truncation occurred.
6363
*/
64-
PHPAPI size_t php_strlcat(dst, src, siz)
65-
char *dst;
66-
const char *src;
67-
size_t siz;
64+
PHPAPI size_t php_strlcat(char *dst, const char *src, size_t siz)
6865
{
6966
const char *d = dst;
7067
const char *s = src;

main/strlcpy.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,7 @@ static const char *rcsid = "$OpenBSD: strlcpy.c,v 1.15 2016/10/16 17:37:39 dtuck
5959
* will be copied. Always NUL terminates (unless siz == 0).
6060
* Returns strlen(src); if retval >= siz, truncation occurred.
6161
*/
62-
PHPAPI size_t php_strlcpy(dst, src, siz)
63-
char *dst;
64-
const char *src;
65-
size_t siz;
62+
PHPAPI size_t php_strlcpy(char *dst, const char *src, size_t siz)
6663
{
6764
const char *s = src;
6865
size_t n = siz;
@@ -83,12 +80,7 @@ PHPAPI size_t php_strlcpy(dst, src, siz)
8380
;
8481
}
8582

86-
/*
87-
* Cast pointers to unsigned type before calculation, to avoid signed
88-
* overflow when the string ends where the MSB has changed.
89-
* Return value does not include NUL.
90-
*/
91-
return((uintptr_t)src - (uintptr_t)s - 1);
83+
return(src - s - 1);
9284
}
9385

9486
#endif /* !HAVE_STRLCPY */

0 commit comments

Comments
 (0)