Source-Changes-HG archive

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

[src/trunk]: src/bin/cat more complete fix for Coverity issue 976653



details:   https://anonhg.NetBSD.org/src/rev/38f109b737e8
branches:  trunk
changeset: 791875:38f109b737e8
user:      spz <spz%NetBSD.org@localhost>
date:      Sun Dec 08 08:32:13 2013 +0000

description:
more complete fix for Coverity issue 976653

diffstat:

 bin/cat/cat.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (32 lines):

diff -r ff17da4ecd75 -r 38f109b737e8 bin/cat/cat.c
--- a/bin/cat/cat.c     Sun Dec 08 08:30:01 2013 +0000
+++ b/bin/cat/cat.c     Sun Dec 08 08:32:13 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cat.c,v 1.53 2013/12/03 17:06:51 spz Exp $ */
+/* $NetBSD: cat.c,v 1.54 2013/12/08 08:32:13 spz Exp $ */
 
 /*
  * Copyright (c) 1989, 1993
@@ -44,7 +44,7 @@
 #if 0
 static char sccsid[] = "@(#)cat.c      8.2 (Berkeley) 4/27/95";
 #else
-__RCSID("$NetBSD: cat.c,v 1.53 2013/12/03 17:06:51 spz Exp $");
+__RCSID("$NetBSD: cat.c,v 1.54 2013/12/08 08:32:13 spz Exp $");
 #endif
 #endif /* not lint */
 
@@ -279,10 +279,11 @@
                                continue;
                        }
                        filename = *argv++;
+               } else if (fd < 0) {
+                       err(EXIT_FAILURE, "stdin");
                }
                raw_cat(fd);
-               /* fd > 0 would be cuter but let's priorize human-readability */
-               if (fd >= 0 && fd != fileno(stdin))
+               if (fd != fileno(stdin))
                        (void)close(fd);
        } while (*argv);
 }



Home | Main Index | Thread Index | Old Index