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 \0-terminate the result.
details: https://anonhg.NetBSD.org/src/rev/bf5c68e07f17
branches: trunk
changeset: 513544:bf5c68e07f17
user: itojun <itojun%NetBSD.org@localhost>
date: Fri Aug 03 09:18:58 2001 +0000
description:
fgetln() does not \0-terminate the result.
diffstat:
usr.sbin/sushi/scanform.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diffs (21 lines):
diff -r d339cebf1a3f -r bf5c68e07f17 usr.sbin/sushi/scanform.c
--- a/usr.sbin/sushi/scanform.c Fri Aug 03 06:02:42 2001 +0000
+++ b/usr.sbin/sushi/scanform.c Fri Aug 03 09:18:58 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: scanform.c,v 1.19 2001/08/01 09:08:55 garbled Exp $ */
+/* $NetBSD: scanform.c,v 1.20 2001/08/03 09:18:58 itojun Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -1127,7 +1127,10 @@
if (ftp->list == NULL)
bailout("malloc: %s", strerror(errno));
- for (i=0; (p = fgetln(file, &len)) != NULL; i++ ) {
+ for (i = 0; (p = fgetln(file, &len)) != NULL; i++) {
+ if (len == 1)
+ continue;
+ p[len - 1] = '\0'; /* NUL terminate */
ftp->list[i] = strdup(p);
ftp->list[i][len -1] = '\0';
ftp->list = realloc(ftp->list, sizeof(char *) * (i+2));
Home |
Main Index |
Thread Index |
Old Index