com php-src: Sync strlcat() implementation: main/strlcat.c
| From: | Nikita Popov | Date: | Fri, 25 Aug 2017 20:12:23 +0000 |
| Subject: | com php-src: Sync strlcat() implementation: main/strlcat.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-99165@lists.php.net to get a copy of this message | ||
Commit: 24c0a17d7879c2fe2ff8d368e3e43ad3a818db8e
Author: David Carlier <devnexen@gmail.com> Thu, 24 Aug 2017 06:58:15 +0100
Committer: Nikita Popov <nikita.ppv@gmail.com> Fri, 25 Aug 2017 22:12:23 +0200
Parents: 3ef89649976e1c05c981c3004a12cf3d9e001822
Branches: PHP-7.2 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=24c0a17d7879c2fe2ff8d368e3e43ad3a818db8e
Log:
Sync strlcat() implementation
Sync with last version made few days after.
Changed paths:
M main/strlcat.c
Diff:
diff --git a/main/strlcat.c b/main/strlcat.c
index d3c8972..c87f3fd 100644
--- a/main/strlcat.c
+++ b/main/strlcat.c
@@ -22,7 +22,7 @@
#ifdef USE_STRLCAT_PHP_IMPL
-/* $OpenBSD: strlcat.c,v 1.17 2016/10/14 18:19:04 dtucker Exp $ */
+/* $OpenBSD: strlcat.c,v 1.18 2016/10/16 17:37:39 dtucker Exp $ */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -61,8 +61,9 @@ static char *rcsid = "$OpenBSD: strlcat.c,v 1.17 2016/10/14 18:19:04 dtucker
Exp
/*
* Appends src to string dst of size siz (unlike strncat, siz is the
* full size of dst, not space left). At most siz-1 characters
- * will be copied. Always NUL terminates (unless siz == 0).
- * Returns strlen(src); if retval >= siz, truncation occurred.
+ * will be copied. Always NUL terminates (unless siz <= strlen(dst)).
+ * Returns strlen(src) + MIN(siz, strlen(initial dst)..
+ * If retval >= siz, truncation occurred.
*/
PHPAPI size_t php_strlcat(dst, src, siz)
char *dst;
@@ -77,7 +78,7 @@ PHPAPI size_t php_strlcat(dst, src, siz)
/* Find the end of dst and adjust bytes left but don't go past end */
while (n-- != 0 && *dst != '\0')
dst++;
- dlen = (uintptr_t)dst - (uintptr_t)d;
+ dlen = dst - d;
n = siz - dlen;
if (n-- == 0)
@@ -91,12 +92,7 @@ PHPAPI size_t php_strlcat(dst, src, siz)
}
*dst = '\0';
- /*
- * 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(dlen + ((uintptr_t)src - (uintptr_t)s));
+ return(dlen + (src - s));
}
#endif /* !HAVE_STRLCAT */