Browse Source

fix an off-by-one error where the return value would point to the

character after the '\0'; ok guenther@
OPENBSD_5_2
naddy 12 years ago
parent
commit
2cc386be9a
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      src/lib/libc/string/stpncpy.c

+ 2
- 2
src/lib/libc/string/stpncpy.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: stpncpy.c,v 1.1 2012/01/17 02:48:01 guenther Exp $ */
/* $OpenBSD: stpncpy.c,v 1.2 2012/07/11 10:44:59 naddy Exp $ */
/*- /*-
* Copyright (c) 1990 The Regents of the University of California. * Copyright (c) 1990 The Regents of the University of California.
@ -44,7 +44,7 @@ stpncpy(char *dst, const char *src, size_t n)
dst = &dst[n]; dst = &dst[n];
do { do {
if ((*d++ = *s++) == 0) { if ((*d++ = *s++) == 0) {
dst = d;
dst = d - 1;
/* NUL pad the remaining n-1 bytes */ /* NUL pad the remaining n-1 bytes */
while (--n != 0) while (--n != 0)
*d++ = 0; *d++ = 0;


Loading…
Cancel
Save