Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Jan 2015 14:36:03 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r277933 - stable/10/usr.bin/sed
Message-ID:  <201501301436.t0UEa3it067280@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Fri Jan 30 14:36:02 2015
New Revision: 277933
URL: https://svnweb.freebsd.org/changeset/base/277933

Log:
  MFC	r277802, r277811:
  
  sed: Fix resource leak and dereference after NULL.
  
  process.c:
  Protect access against NULL.
  
  main.c:
  Prevent outfile overwrite resource leak.
  
  CID:	271181
  CID:	1006930
  
  Obtained from:	NetBSD

Modified:
  stable/10/usr.bin/sed/main.c
  stable/10/usr.bin/sed/process.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.bin/sed/main.c
==============================================================================
--- stable/10/usr.bin/sed/main.c	Fri Jan 30 14:35:04 2015	(r277932)
+++ stable/10/usr.bin/sed/main.c	Fri Jan 30 14:36:02 2015	(r277933)
@@ -409,6 +409,8 @@ mf_fgets(SPACE *sp, enum e_spflag spflag
 			if (len >= sizeof(tmpfname))
 				errx(1, "%s: name too long", fname);
 			unlink(tmpfname);
+			if (outfile != NULL && outfile != stdout)
+				fclose(outfile);
 			if ((outfile = fopen(tmpfname, "w")) == NULL)
 				err(1, "%s", fname);
 			fchown(fileno(outfile), sb.st_uid, sb.st_gid);

Modified: stable/10/usr.bin/sed/process.c
==============================================================================
--- stable/10/usr.bin/sed/process.c	Fri Jan 30 14:35:04 2015	(r277932)
+++ stable/10/usr.bin/sed/process.c	Fri Jan 30 14:36:02 2015	(r277933)
@@ -314,7 +314,7 @@ applies(struct s_command *cp)
                                 } else
                                         r = 1;
                         }
-		} else if (MATCH(cp->a1)) {
+		} else if (cp->a1 && MATCH(cp->a1)) {
 			/*
 			 * If the second address is a number less than or
 			 * equal to the line number first selected, only



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201501301436.t0UEa3it067280>