Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sup/source fix problem with fgets()



details:   https://anonhg.NetBSD.org/src/rev/c75ef0fc22c5
branches:  trunk
changeset: 545218:c75ef0fc22c5
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Apr 04 23:10:10 2003 +0000

description:
fix problem with fgets()

diffstat:

 usr.sbin/sup/source/read_line.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (41 lines):

diff -r c0672e68e24b -r c75ef0fc22c5 usr.sbin/sup/source/read_line.c
--- a/usr.sbin/sup/source/read_line.c   Fri Apr 04 22:38:05 2003 +0000
+++ b/usr.sbin/sup/source/read_line.c   Fri Apr 04 23:10:10 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: read_line.c,v 1.6 2003/04/03 17:14:24 christos Exp $   */
+/*     $NetBSD: read_line.c,v 1.7 2003/04/04 23:10:10 christos Exp $   */
 
 /*
  * Copyright (c) 1994 Mats O Jansson <moj%stacken.kth.se@localhost>
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 #if defined(lint) && defined(__RCSID)
-__RCSID("$NetBSD: read_line.c,v 1.6 2003/04/03 17:14:24 christos Exp $");
+__RCSID("$NetBSD: read_line.c,v 1.7 2003/04/04 23:10:10 christos Exp $");
 #endif
 
 #include <sys/param.h>
@@ -89,11 +89,12 @@
                }
 #else
                if ((ptr = fgets(sbuf, sizeof(sbuf) - 1, fp)) == NULL) {
-                       char *l;
                        if (len == 0)
                                return NULL;
                        else
                                return buf;
+               } else {
+                       char *l;
                        if ((l = strchr(sbuf, '\n')) == NULL) {
                                if (sbuf[sizeof(sbuf) - 3] != '\\') {
                                        s = sizeof(sbuf);
@@ -102,7 +103,7 @@
                                } else
                                        s = sizeof(sbuf) - 1;
                        } else {
-                               s = l - ptr;
+                               s = l - sbuf;
                        }
                }
 #endif



Home | Main Index | Thread Index | Old Index