diff options
| author | naddy <> | 2012-07-11 10:46:23 +0000 |
|---|---|---|
| committer | naddy <> | 2012-07-11 10:46:23 +0000 |
| commit | 9283e994e1f0fa8fea96e9052188e12290956ad3 (patch) | |
| tree | 1a80b9d610bafa8678620c1004774a4bac9764a4 /src | |
| parent | ee4e924e8a4518efe5788a280baa0fbb30d302e1 (diff) | |
| download | openbsd-9283e994e1f0fa8fea96e9052188e12290956ad3.tar.gz openbsd-9283e994e1f0fa8fea96e9052188e12290956ad3.tar.bz2 openbsd-9283e994e1f0fa8fea96e9052188e12290956ad3.zip | |
catch off-by-one errors in stpncpy(); ok guenther@
Diffstat (limited to '')
| -rw-r--r-- | src/regress/lib/libc/Makefile | 12 | ||||
| -rw-r--r-- | src/regress/lib/libc/stpncpy/Makefile | 3 | ||||
| -rw-r--r-- | src/regress/lib/libc/stpncpy/stpncpy_test.c | 24 |
3 files changed, 33 insertions, 6 deletions
diff --git a/src/regress/lib/libc/Makefile b/src/regress/lib/libc/Makefile index 24749b95b4..a0b950033e 100644 --- a/src/regress/lib/libc/Makefile +++ b/src/regress/lib/libc/Makefile | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.33 2011/07/02 18:12:48 martynas Exp $ | 1 | # $OpenBSD: Makefile,v 1.34 2012/07/11 10:46:23 naddy Exp $ |
| 2 | 2 | ||
| 3 | SUBDIR+= _setjmp alloca atexit basename cxa-atexit db dirname fnmatch | 3 | SUBDIR+= _setjmp alloca atexit basename cephes cxa-atexit db dirname env |
| 4 | SUBDIR+= fpclassify getaddrinfo getcap getopt_long glob hsearch longjmp | 4 | SUBDIR+= fnmatch fpclassify getaddrinfo getcap getopt_long glob hsearch |
| 5 | SUBDIR+= locale malloc netdb popen printf regex setjmp setjmp-signal | 5 | SUBDIR+= longjmp locale malloc mkstemp netdb orientation popen printf |
| 6 | SUBDIR+= sigreturn sigsetjmp sprintf strerror strtod strtonum telldir time vis | 6 | SUBDIR+= regex setjmp setjmp-signal sigreturn sigsetjmp sprintf |
| 7 | SUBDIR+= orientation stdio_threading mkstemp env cephes | 7 | SUBDIR+= stdio_threading stpncpy strerror strtod strtonum telldir time vis |
| 8 | 8 | ||
| 9 | .if (${MACHINE_ARCH} != "vax") | 9 | .if (${MACHINE_ARCH} != "vax") |
| 10 | SUBDIR+= ieeefp | 10 | SUBDIR+= ieeefp |
diff --git a/src/regress/lib/libc/stpncpy/Makefile b/src/regress/lib/libc/stpncpy/Makefile new file mode 100644 index 0000000000..9333934da6 --- /dev/null +++ b/src/regress/lib/libc/stpncpy/Makefile | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | PROG=stpncpy_test | ||
| 2 | |||
| 3 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libc/stpncpy/stpncpy_test.c b/src/regress/lib/libc/stpncpy/stpncpy_test.c new file mode 100644 index 0000000000..63b7d25e53 --- /dev/null +++ b/src/regress/lib/libc/stpncpy/stpncpy_test.c | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | /* $OpenBSD: stpncpy_test.c,v 1.1 2012/07/11 10:46:23 naddy Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Public domain, 2012, Christian Weisgerber <naddy@openbsd.org> | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <string.h> | ||
| 8 | |||
| 9 | int main(void) | ||
| 10 | { | ||
| 11 | char dst[8]; | ||
| 12 | char *src = "abcdef"; | ||
| 13 | |||
| 14 | if (stpncpy(dst, src, 5) != dst + 5) | ||
| 15 | return 1; | ||
| 16 | if (stpncpy(dst, src, 6) != dst + 6) | ||
| 17 | return 1; | ||
| 18 | if (stpncpy(dst, src, 7) != dst + 6) | ||
| 19 | return 1; | ||
| 20 | if (stpncpy(dst, src, 8) != dst + 6) | ||
| 21 | return 1; | ||
| 22 | |||
| 23 | return 0; | ||
| 24 | } | ||
