Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/sushi fgetln() does NOT return NUL-terminated string



details:   https://anonhg.NetBSD.org/src/rev/1d167f966e2e
branches:  trunk
changeset: 534443:1d167f966e2e
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Fri Jul 26 07:59:33 2002 +0000

description:
fgetln() does NOT return NUL-terminated string
This fixes bin/13624 by Jun-ichiro itojun Hagino

diffstat:

 usr.sbin/sushi/scanform.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (29 lines):

diff -r d430ca5f352d -r 1d167f966e2e usr.sbin/sushi/scanform.c
--- a/usr.sbin/sushi/scanform.c Fri Jul 26 07:29:06 2002 +0000
+++ b/usr.sbin/sushi/scanform.c Fri Jul 26 07:59:33 2002 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: scanform.c,v 1.23 2002/07/25 12:42:39 jdolecek Exp $       */
+/*      $NetBSD: scanform.c,v 1.24 2002/07/26 07:59:33 jdolecek Exp $       */
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -1226,8 +1226,8 @@
 
        p = fgetln(file, &len);
        if (p != NULL) {
+               p[len - 1] = '\0';      /* strip newline & NUL terminate */
                q = strdup(p);
-               q[len -1] = '\0';
        } else
                bailout("fgetln: %s", strerror(errno));
 
@@ -1337,8 +1337,8 @@
 
        p = fgetln(file, &len);
        if (p != NULL) {
+               p[len - 1] = '\0';      /* strip newline & NUL terminate */
                q = strdup(p);
-               q[len -1] = '\0';
        } else
                bailout("fgetln: %s", strerror(errno));
 



Home | Main Index | Thread Index | Old Index