diff options
author | 2016-10-16 17:37:39 +0000 | |
---|---|---|
committer | 2016-10-16 17:37:39 +0000 | |
commit | 5cc8e0fffcd2953afeae0870adb6697854383066 (patch) | |
tree | 6bf25cec149a4691b0eadd57259c3179775897bc /lib/libc/string/strlcpy.c | |
parent | Strip trailing obj/ from kernel build directories, so kernels (diff) | |
download | wireguard-openbsd-5cc8e0fffcd2953afeae0870adb6697854383066.tar.xz wireguard-openbsd-5cc8e0fffcd2953afeae0870adb6697854383066.zip |
Roll back uintptr_t cast changes after discussions with tedu, otto and
others.
C11 6.5.6.9 says:
When two pointers are subtracted, both shall point to elements of the
same array object, or one past the last element of the array object; the
result is the difference of the subscripts of the two array elements.
In these cases the objects are arrays of char so the result is defined,
and we believe that the report is based on a compiler incorrectly trapping
on defined behaviour.
Diffstat (limited to 'lib/libc/string/strlcpy.c')
-rw-r--r-- | lib/libc/string/strlcpy.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/lib/libc/string/strlcpy.c b/lib/libc/string/strlcpy.c index f2828346801..367768928db 100644 --- a/lib/libc/string/strlcpy.c +++ b/lib/libc/string/strlcpy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strlcpy.c,v 1.14 2016/10/14 18:19:04 dtucker Exp $ */ +/* $OpenBSD: strlcpy.c,v 1.15 2016/10/16 17:37:39 dtucker Exp $ */ /* * Copyright (c) 1998, 2015 Todd C. Miller <Todd.Miller@courtesan.com> @@ -18,7 +18,6 @@ #include <sys/types.h> #include <string.h> -#include <stdint.h> /* * Copy string src to buffer dst of size dsize. At most dsize-1 @@ -47,11 +46,6 @@ strlcpy(char *dst, const char *src, size_t dsize) ; } - /* - * 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)osrc - 1); + return(src - osrc - 1); /* count does not include NUL */ } DEF_WEAK(strlcpy); |