Debian Bug report logs - #7522
dpkg uses wrong test for fputs() return value

Package: dpkg; Maintainer for dpkg is Dpkg Developers <debian-dpkg@lists.debian.org>; Source for dpkg is src:dpkg (PTS, buildd, popcon).

Reported by: Klee Dienes <klee@mit.edu>

Date: Fri, 21 Feb 1997 06:03:06 UTC

Severity: normal

Done: Anthony Towns <ajt@master.debian.org>

Bug is archived. No further changes may be made.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to Ian Jackson <ian@chiark.greenend.org.uk>:
Bug#7522; Package dpkg. (full text, mbox, link).


Acknowledgement sent to Klee Dienes <klee@mit.edu>:
New bug report received and forwarded. Copy sent to Ian Jackson <ian@chiark.greenend.org.uk>. (full text, mbox, link).


Message #5 received at maintonly@bugs.debian.org (full text, mbox, reply):

From: Klee Dienes <klee@mit.edu>
To: maintonly@bugs.debian.org
Subject: dpkg uses wrong test for fputs() return value
Date: Fri, 21 Feb 1997 00:52:45 -0500
Package: dpkg
Version: 1.4.0.8

From 4.9.7.4 of the ANSI C standard:

"The fputs function returns EOF if a write error occurs; otherwise it
returns a nonnegative value."

The code in dpkg all checks for (ret != 0) instead of (ret >= 0).
This appears to have no serious effects in the code (fputs appears to
only be used for printing error and status messages), but it leads to
annoying error messages under GNU/Win32.

A patch is appended:

diff -ru dpkg-1.4.0.8/dpkg-deb/info.c dpkg-1.4.0.8-1.1/dpkg-deb/info.c
--- dpkg-1.4.0.8/dpkg-deb/info.c	Tue Aug 20 09:14:43 1996
+++ dpkg-1.4.0.8-1.1/dpkg-deb/info.c	Sun Feb 16 02:49:51 1997
@@ -151,9 +155,9 @@
         werr("stdout");
     }
   }
   if (!(cc= fopen("control","r"))) {
     if (errno != ENOENT) ohshite("failed to read `control' (in `%.255s')",directory);
-    if (!fputs("(no `control' file in control archive!)\n",stdout)) werr("stdout");
+    if (fputs("(no `control' file in control archive!)\n",stdout) < 0) werr("stdout");
   } else {
     lines= 1;
     while ((c= getc(cc))!= EOF) {
diff -ru dpkg-1.4.0.8/dpkg-deb/main.c dpkg-1.4.0.8-1.1/dpkg-deb/main.c
--- dpkg-1.4.0.8/dpkg-deb/main.c	Wed May 15 18:35:00 1996
+++ dpkg-1.4.0.8-1.1/dpkg-deb/main.c	Mon Feb 17 08:07:09 1997
@@ -40,16 +41,16 @@
 #include "dpkg-deb.h"
 
 static void printversion(void) {
-  if (!fputs("Debian Linux `" BACKEND "' package archive backend "
-             "version " DPKG_VERSION_ARCH ".\n"
-             "Copyright (C) 1994-1996 Ian Jackson.  This is free software; see the\n"
-             "GNU General Public Licence version 2 or later for copying conditions.\n"
-             "There is NO warranty.  See dpkg-deb --licence for details.\n",
-             stdout)) werr("stdout");
+  if (fputs("Debian Linux `" BACKEND "' package archive backend "
+	    "version " DPKG_VERSION_ARCH ".\n"
+	    "Copyright (C) 1994-1996 Ian Jackson.  This is free software; see the\n"
+	    "GNU General Public Licence version 2 or later for copying conditions.\n"
+	    "There is NO warranty.  See dpkg-deb --licence for details.\n",
+	    stdout) < 0) werr("stdout");
 }
 
 static void usage(void) {
-  if (!fputs("\
+  if (fputs("\
 Usage: " BACKEND " -b|--build <directory> [<deb>]    Build an archive.\n\
        " BACKEND " -c|--contents <deb>               List contents.\n\
        " BACKEND " -I|--info <deb> [<cfile>...]      Show info to stdout.\n\
@@ -69,7 +70,7 @@
 Use `" DPKG "' to install and remove packages from your system, or\n\
 `" DSELECT "' for user-friendly package management.  Packages unpacked\n\
 using `" BACKEND " --extract' will be incorrectly installed !\n",
-             stdout)) werr("stdout");
+             stdout) < 0) werr("stdout");
 }
 
 const char thisname[]= BACKEND;
diff -ru dpkg-1.4.0.8/lib/dump.c dpkg-1.4.0.8-1.1/lib/dump.c
--- dpkg-1.4.0.8/lib/dump.c	Wed May 15 20:19:01 1996
+++ dpkg-1.4.0.8-1.1/lib/dump.c	Sun Feb 16 02:51:03 1997
@@ -218,7 +218,7 @@
   varbufinit(&vb);
   varbufrecord(&vb,pigp,pifp);
   varbufaddc(&vb,'\0');
-  if (!fputs(vb.buf,file))
+  if (fputs(vb.buf,file) < 0)
     ohshite("failed to write details of `%.50s' to `%.250s'", pigp->name, filename);
 }
 
@@ -254,7 +254,7 @@
     if (!pifp->valid) blankpackageperfile(pifp);
     varbufrecord(&vb,pigp,pifp);
     varbufaddc(&vb,'\n'); varbufaddc(&vb,0);
-    if (!fputs(vb.buf,file))
+    if (fputs(vb.buf,file) < 0)
       ohshite("failed to write %s record about `%.50s' to `%.250s'",
               which, pigp->name, filename);
     varbufreset(&vb);      
diff -ru dpkg-1.4.0.8/main/main.c dpkg-1.4.0.8-1.1/main/main.c
--- dpkg-1.4.0.8/main/main.c	Sat Jan 25 15:06:28 1997
+++ dpkg-1.4.0.8-1.1/main/main.c	Mon Feb 17 08:07:36 1997
@@ -41,19 +42,19 @@
 #include "main.h"
 
 static void printversion(void) {
-  if (!fputs("Debian Linux `" DPKG "' package management program version "
-              DPKG_VERSION_ARCH ".\n"
-             "Copyright 1994-1996 Ian Jackson, Bruce Perens.  This is free software;\n"
-             "see the GNU General Public Licence version 2 or later for copying\n"
-             "conditions.  There is NO warranty.  See dpkg --licence for details.\n",
-             stdout)) werr("stdout");
+  if (fputs("Debian Linux `" DPKG "' package management program version "
+	    DPKG_VERSION_ARCH ".\n"
+	    "Copyright 1994-1996 Ian Jackson, Bruce Perens.  This is free software;\n"
+	    "see the GNU General Public Licence version 2 or later for copying\n"
+	    "conditions.  There is NO warranty.  See dpkg --licence for details.\n",
+	    stdout) < 0) werr("stdout");
 }
 /*
    options that need fixing:
   " DPKG " --yet-to-unpack                 \n\
   */
 static void usage(void) {
-  if (!fputs("\
+  if (fputs("\
 Usage: \n\
   " DPKG " -i|--install      <.deb file name> ... | -R|--recursive <dir> ...\n\
   " DPKG " --unpack          <.deb file name> ... | -R|--recursive <dir> ...\n\
@@ -107,7 +108,7 @@
  < << <= = >= >> >       (only for compatibility with control file syntax).\n\
 \n\
 Use `" DSELECT "' for user-friendly package management.\n",
-             stdout)) werr("stdout");
+             stdout) < 0) werr("stdout");
 }
 
 const char thisname[]= DPKG;
@@ -174,7 +175,7 @@
   char *endp;
 
   if (*value == 'h') {
-    if (!fputs(
+    if (fputs(
 DPKG " debugging option, --debug=<octal> or -D<octal>:\n\n\
  number  ref. in source   description\n\
       1   general           Generally helpful progress information\n\
@@ -189,7 +190,7 @@
    2000   stupidlyverbose   Insane amounts of drivel\n\n\
 Debugging options are be mixed using bitwise-or.\n\
 Note that the meanings and values are subject to change.\n",
-             stderr)) werr("stderr");
+             stderr) < 0) werr("stderr");
     exit(0);
   }
   
@@ -240,7 +241,7 @@
   const struct forceinfo *fip;
 
   if (!strcmp(value,"help")) {
-    if (!fputs(
+    if (fputs(
 DPKG " forcing options - control behaviour when problems found:\n\
   warn but continue:  --force-<thing>,<thing>,...\n\
   stop with error:    --refuse-<thing>,<thing>,... | --no-force-<thing>,...\n\
@@ -263,7 +264,7 @@
 \n\
 WARNING - use of options marked [!] can seriously damage your installation.\n\
 Forcing options marked [*] are enabled by default.\n",
-               stderr)) werr("stderr");
+               stderr) < 0) werr("stderr");
     exit(0);
   }
 
diff -ru dpkg-1.4.0.8/split/main.c dpkg-1.4.0.8-1.1/split/main.c
--- dpkg-1.4.0.8/split/main.c   Wed May 15 18:35:00 1996
+++ dpkg-1.4.0.8-1.1/split/main.c       Sun Feb 16 02:52:32 1997
@@ -33,17 +33,17 @@
 #include "dpkg-split.h"
 
 static void printversion(void) {
-  if (!fputs
+  if (fputs
       ("Debian Linux `" SPLITTER "' package split/join tool; "
        "version " DPKG_VERSION_ARCH ".\n"
        "Copyright (C) 1994-1996 Ian Jackson.  This is free software; see the\n"
        "GNU General Public Licence version 2 or later for copying conditions.\n"
        "There is NO warranty.  See dpkg-split --licence for details.\n",
-       stdout)) werr("stdout");
+       stdout) < 0) werr("stdout");
 }
 
 static void usage(void) {
-  if (!fputs("\
+  if (fputs("\
 Usage: " SPLITTER " -s|--split <file> [<prefix>]     Split an archive.\n\
        " SPLITTER " -j|--join <part> <part> ...      Join parts together.\n\
        " SPLITTER " -I|--info <part> ...             Display info about a part.\n\
@@ -60,7 +60,7 @@
           --msdos                 (generate 8.3 filenames)\n\
 \n\
 Exit status: 0 = OK;  1 = -a is not a part;  2 = trouble!\n",
-             stdout)) werr("stdout");
+             stdout) < 0) werr("stdout");
 }
 
 const char thisname[]= SPLITTER;


Information forwarded to debian-bugs-dist@lists.debian.org, Klee Dienes and Ian Jackson <dpkg-maint@chiark.greenend.org.uk>:
Bug#7522; Package dpkg. (full text, mbox, link).


Acknowledgement sent to Juan Cespedes <cespedes@debian.org>:
Extra info received and forwarded to list. Copy sent to Klee Dienes and Ian Jackson <dpkg-maint@chiark.greenend.org.uk>. (full text, mbox, link).


Message #10 received at 7522@bugs.debian.org (full text, mbox, reply):

From: Juan Cespedes <cespedes@debian.org>
To: 7522@bugs.debian.org
Cc: Klee Dienes <klee@mit.edu>
Subject: Re: Bug#7522: dpkg uses wrong test for fputs() return value
Date: Sat, 4 Apr 1998 20:38:02 +0200
	This bug has already been fixed.  Can it be closed?

	Thanks.


-- 
Juan Cespedes


Bug reassigned from package `dpkg' to `dpkg-iwj'. Request was from Wichert Akkerman <wichert@cs.leidenuniv.nl> to control@bugs.debian.org. (full text, mbox, link).


Bug reassigned from package `dpkg-iwj' to `dpkg'. Request was from Anthony Towns <ajt@master.debian.org> to control@bugs.debian.org. (full text, mbox, link).


Bug closed, ack sent to submitter - they'd better know why ! Request was from Anthony Towns <ajt@master.debian.org> to control@bugs.debian.org. (full text, mbox, link).


Bug reassigned from package `dpkg' to `dpkg'. Request was from Anthony Towns <ajt@master.debian.org> to control@bugs.debian.org. (full text, mbox, link).


Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Fri Apr 26 00:06:59 2024; Machine Name: bembo

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.