NetBSD Problem Report #45842
From www@NetBSD.org Mon Jan 16 08:33:26 2012
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by www.NetBSD.org (Postfix) with ESMTP id 0D6BB63B931
for <gnats-bugs@gnats.NetBSD.org>; Mon, 16 Jan 2012 08:33:26 +0000 (UTC)
Message-Id: <20120116083325.5103963B84C@www.NetBSD.org>
Date: Mon, 16 Jan 2012 08:33:25 +0000 (UTC)
From: henning.petersen@t-online.de
Reply-To: henning.petersen@t-online.de
To: gnats-bugs@NetBSD.org
Subject: Incorrect comparison fgets.
X-Send-Pr-Version: www-1.0
>Number: 45842
>Category: bin
>Synopsis: Incorrect comparison fgets.
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Jan 16 08:35:00 +0000 2012
>Closed-Date: Sun Jan 22 15:17:56 +0000 2012
>Last-Modified: Sun Jan 22 15:17:56 +0000 2012
>Originator: Henning Petersen
>Release: NetBSD-current
>Organization:
>Environment:
>Description:
Incorrect comparison fgets with integer 0, should be NULL.
>How-To-Repeat:
>Fix:
diff -u -p -r1.13 getcom.c
--- games/battlestar/getcom.c 1 Jul 2005 06:04:54 -0000 1.13
+++ games/battlestar/getcom.c 13 Jan 2012 11:00:30 -0000
@@ -45,7 +45,7 @@ getcom(char *buf, int size, const char *
{
for (;;) {
fputs(prompt, stdout);
- if (fgets(buf, size, stdin) == 0) {
+ if (fgets(buf, size, stdin) == NULL) {
if (feof(stdin))
die();
clearerr(stdin);
===================================================================
RCS file: /cvsroot/src/sbin/routed/parms.c,v
retrieving revision 1.25
diff -u -p -r1.25 parms.c
--- sbin/routed/parms.c 24 May 2011 12:03:04 -0000 1.25
+++ sbin/routed/parms.c 13 Jan 2012 11:00:37 -0000
@@ -192,7 +192,7 @@ gwkludge(void)
}
for (lnum = 1; ; lnum++) {
- if (0 == fgets(lbuf, sizeof(lbuf), fp))
+ if (fgets(lbuf, sizeof(lbuf), fp) == NULL)
break;
lptr = lbuf;
while (*lptr == ' ')
===================================================================
diff -u -p -r1.25 edit.c
--- usr.bin/mail/edit.c 10 Apr 2009 13:08:24 -0000 1.25
+++ usr.bin/mail/edit.c 13 Jan 2012 11:00:39 -0000
@@ -172,7 +172,7 @@ edit1(int *msgvec, int editortype)
char *p;
(void)printf("Edit message %d [ynq]? ", msgvec[i]);
- if (fgets(buf, (int)sizeof(buf), stdin) == 0)
+ if (fgets(buf, (int)sizeof(buf), stdin) == NULL)
break;
p = skip_WSP(buf);
if (*p == 'q')
===================================================================
diff -u -p -r1.29 main.c
--- usr.bin/tftp/main.c 17 Sep 2011 15:15:46 -0000 1.29
+++ usr.bin/tftp/main.c 13 Jan 2012 11:00:44 -0000
@@ -662,7 +662,7 @@ command(void)
for (;;) {
(void)printf("%s> ", prompt);
- if (fgets(line, LBUFLEN, stdin) == 0) {
+ if (fgets(line, LBUFLEN, stdin) == NULL) {
if (feof(stdin)) {
exit(0);
} else {
===================================================================
diff -u -p -r1.21 timedc.c
--- usr.sbin/timed/timedc/timedc.c 21 Jul 2008 13:37:00 -0000 1.21
+++ usr.sbin/timed/timedc/timedc.c 13 Jan 2012 11:00:52 -0000
@@ -105,7 +105,7 @@ main(int argc, char *argv[])
printf("timedc> ");
(void) fflush(stdout);
}
- if (fgets(cmdline, sizeof(cmdline), stdin) == 0)
+ if (fgets(cmdline, sizeof(cmdline), stdin) == NULL)
quit(0, NULL);
>Release-Note:
>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/45842 CVS commit: src
Date: Mon, 16 Jan 2012 12:38:17 -0500
Module Name: src
Committed By: christos
Date: Mon Jan 16 17:38:16 UTC 2012
Modified Files:
src/games/battlestar: getcom.c
src/sbin/routed: parms.c
src/usr.bin/mail: edit.c
src/usr.bin/tftp: main.c
src/usr.sbin/timed/timedc: timedc.c
Log Message:
PR/45842: Henning Petersen: compare fgets with NULL not 0
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/games/battlestar/getcom.c
cvs rdiff -u -r1.25 -r1.26 src/sbin/routed/parms.c
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/mail/edit.c
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/tftp/main.c
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/timed/timedc/timedc.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 22 Jan 2012 15:17:56 +0000
State-Changed-Why:
Christos fixed it
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.