Browse Source

Pass ndigit+1 as size arg to strlcpy() since ndigit doesn't include the NUL

OPENBSD_3_4
millert 21 years ago
parent
commit
96691bd73a
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      src/lib/libc/stdlib/gcvt.c

+ 3
- 3
src/lib/libc/stdlib/gcvt.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: gcvt.c,v 1.2 2003/04/02 02:43:50 millert Exp $ */
/* $OpenBSD: gcvt.c,v 1.3 2003/05/09 20:01:43 millert Exp $ */
/* /*
* Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com> * Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com>
@ -28,7 +28,7 @@
*/ */
#if defined(LIBC_SCCS) && !defined(lint) #if defined(LIBC_SCCS) && !defined(lint)
static char rcsid[] = "$OpenBSD: gcvt.c,v 1.2 2003/04/02 02:43:50 millert Exp $";
static char rcsid[] = "$OpenBSD: gcvt.c,v 1.3 2003/05/09 20:01:43 millert Exp $";
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
#include <stdio.h> #include <stdio.h>
@ -51,7 +51,7 @@ gcvt(double value, int ndigit, char *buf)
digits = __dtoa(value, 2, ndigit, &decpt, &sign, NULL); digits = __dtoa(value, 2, ndigit, &decpt, &sign, NULL);
if (decpt == 9999) { if (decpt == 9999) {
/* Infinity or NaN, assume buffer is at least ndigit long. */ /* Infinity or NaN, assume buffer is at least ndigit long. */
strlcpy(buf, digits, ndigit);
strlcpy(buf, digits, ndigit + 1);
return (buf); return (buf);
} }


Loading…
Cancel
Save