Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/sed CID 10006930: Prevent outfile overwrite resource...



details:   https://anonhg.NetBSD.org/src/rev/abb0eb93dccf
branches:  trunk
changeset: 330081:abb0eb93dccf
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Jun 21 17:43:04 2014 +0000

description:
CID 10006930: Prevent outfile overwrite resource leak.

diffstat:

 usr.bin/sed/main.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (27 lines):

diff -r abb59bf7dbb5 -r abb0eb93dccf usr.bin/sed/main.c
--- a/usr.bin/sed/main.c        Sat Jun 21 17:34:30 2014 +0000
+++ b/usr.bin/sed/main.c        Sat Jun 21 17:43:04 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.27 2014/06/18 14:15:50 christos Exp $       */
+/*     $NetBSD: main.c,v 1.28 2014/06/21 17:43:04 christos Exp $       */
 
 /*-
  * Copyright (c) 2013 Johann 'Myrkraverk' Oskarsson.
@@ -39,7 +39,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: main.c,v 1.27 2014/06/18 14:15:50 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.28 2014/06/21 17:43:04 christos Exp $");
 #ifdef __FBSDID
 __FBSDID("$FreeBSD: head/usr.bin/sed/main.c 252231 2013-06-26 04:14:19Z pfg $");
 #endif
@@ -427,6 +427,8 @@
                        if (len >= sizeof(tmpfname))
                                errx(1, "%s: name too long", fname);
                        unlink(tmpfname);
+                       if (outfile != NULL && outfile != stdout)
+                               flose(outfile);
                        if ((outfile = fopen(tmpfname, "w")) == NULL)
                                err(1, "%s", fname);
                        fchown(fileno(outfile), sb.st_uid, sb.st_gid);



Home | Main Index | Thread Index | Old Index