From nobody@FreeBSD.org  Wed Aug 14 21:10:19 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTP id 1DCC81AE
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 14 Aug 2013 21:10:19 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 0AE942754
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 14 Aug 2013 21:10:19 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id r7ELAICI000791
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 14 Aug 2013 21:10:18 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id r7ELAIYU000770;
	Wed, 14 Aug 2013 21:10:18 GMT
	(envelope-from nobody)
Message-Id: <201308142110.r7ELAIYU000770@oldred.freebsd.org>
Date: Wed, 14 Aug 2013 21:10:18 GMT
From: Garrett Cooper <yaneurabeya@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: gzip can leave corrupt files lingering around a filesystem in the event that a signal != SIGINT was received or the program exited in before completeing the file_compress function
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         181309
>Category:       bin
>Synopsis:       gzip(1) can leave corrupt files lingering around a filesystem in the event that a signal != SIGINT was received or the program exited in before completeing the file_compress function
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug 14 21:20:00 UTC 2013
>Closed-Date:    
>Last-Modified:  Thu Aug 15 03:05:58 UTC 2013
>Originator:     Garrett Cooper
>Release:        10-CURRENT
>Organization:
EMC Isilon
>Environment:
FreeBSD gran-tourismo.west.isilon.com 10.0-CURRENT FreeBSD 10.0-CURRENT #8 bc57ffb: Fri Aug  2 15:14:32 PDT 2013     root@:/usr/obj/usr/src/sys/GRAN-TOURISMO  amd64
>Description:
We have a number of bugs filed for newsyslog compression failure issues open at work due to panics at the time of log rotation, and the like. I did some code inspection and I realized that there are some design flaws with gzip(1). In particular:

1. gzip doesn't use mkstemp and it really should (not using mkstemp means that multiple accesses to the same file can create corrupt gzip files potentially or result in unexpected behavior). renames of the gzip'ed content to a temporary file are guaranteed to be more atomic than writing out to the file itself.
2. It's assumed that if the file_compress function will run to completion, and in which case files can be deleted (which is indeed not the case with some of the code paths in gz_compress that call maybe_err*).
>How-To-Repeat:

>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:
