1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-27 00:57:50 +00:00

Add the missing parts from FreeBSD-SA-05:14.bzip2

See
ftp://ftp.freebsd.org/pub/FreeBSD/CERT/advisories/FreeBSD-SA-05:14.bzip2.asc
and the discussion on -ports about it.

Approved by:	no reply from maintainer and pushed by members of so@
This commit is contained in:
Edwin Groothuis 2005-10-20 10:01:05 +00:00
parent 26b7449a68
commit 92588a2f7a
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=145923
2 changed files with 94 additions and 0 deletions

View File

@ -8,6 +8,7 @@
PORTNAME= bzip2
PORTVERSION= 1.0.3
PORTREVISION= 1
CATEGORIES= archivers
MASTER_SITES= http://www.bzip.org/${PORTVERSION}/
@ -15,6 +16,7 @@ MAINTAINER= jharris@widomaker.com
COMMENT= A block-sorting file compressor
INSTALLS_SHLIB= yes
PATCH_STRIP= -p3
MAN1= bzip2.1 bzgrep.1 bzmore.1
MLINKS= bzip2.1 bunzip2.1 bzip2.1 bzcat.1 bzip2.1 bz2cat.1 \

View File

@ -0,0 +1,92 @@
--- bzip2.c.orig Wed Feb 16 03:25:35 2005
+++ bzip2.c Sun Oct 16 09:47:40 2005
@@ -312,6 +312,7 @@
static void copyFileName ( Char*, Char* );
static void* myMalloc ( Int32 );
+static int applySavedFileAttrToOutputFile ( int fd );
@@ -457,6 +458,10 @@
ret = fflush ( zStream );
if (ret == EOF) goto errhandler_io;
if (zStream != stdout) {
+ int fd = fileno ( zStream );
+ if (fd < 0) goto errhandler_io;
+ ret = applySavedFileAttrToOutputFile ( fd );
+ if (ret != 0) goto errhandler_io;
ret = fclose ( zStream );
outputHandleJustInCase = NULL;
if (ret == EOF) goto errhandler_io;
@@ -569,6 +574,12 @@
closeok:
if (ferror(zStream)) goto errhandler_io;
+ if ( stream != stdout) {
+ int fd = fileno ( stream );
+ if (fd < 0) goto errhandler_io;
+ ret = applySavedFileAttrToOutputFile ( fd );
+ if (ret != 0) goto errhandler_io;
+ }
ret = fclose ( zStream );
if (ret == EOF) goto errhandler_io;
@@ -1129,7 +1140,7 @@
static
-void applySavedMetaInfoToOutputFile ( Char *dstName )
+void applySavedTimeInfoToOutputFile ( Char *dstName )
{
# if BZ_UNIX
IntNative retVal;
@@ -1138,16 +1149,26 @@
uTimBuf.actime = fileMetaInfo.st_atime;
uTimBuf.modtime = fileMetaInfo.st_mtime;
- retVal = chmod ( dstName, fileMetaInfo.st_mode );
- ERROR_IF_NOT_ZERO ( retVal );
-
retVal = utime ( dstName, &uTimBuf );
ERROR_IF_NOT_ZERO ( retVal );
+# endif
+}
+
+static
+int applySavedFileAttrToOutputFile ( int fd )
+{
+# if BZ_UNIX
+ IntNative retVal;
+
+ retVal = fchmod ( fd, fileMetaInfo.st_mode );
+ if (retVal != 0)
+ return retVal;
- retVal = chown ( dstName, fileMetaInfo.st_uid, fileMetaInfo.st_gid );
+ (void) fchown ( fd, fileMetaInfo.st_uid, fileMetaInfo.st_gid );
/* chown() will in many cases return with EPERM, which can
be safely ignored.
*/
+ return 0;
# endif
}
@@ -1370,7 +1391,7 @@
/*--- If there was an I/O error, we won't get here. ---*/
if ( srcMode == SM_F2F ) {
- applySavedMetaInfoToOutputFile ( outName );
+ applySavedTimeInfoToOutputFile ( outName );
deleteOutputOnInterrupt = False;
if ( !keepInputFiles ) {
IntNative retVal = remove ( inName );
@@ -1548,7 +1569,7 @@
/*--- If there was an I/O error, we won't get here. ---*/
if ( magicNumberOK ) {
if ( srcMode == SM_F2F ) {
- applySavedMetaInfoToOutputFile ( outName );
+ applySavedTimeInfoToOutputFile ( outName );
deleteOutputOnInterrupt = False;
if ( !keepInputFiles ) {
IntNative retVal = remove ( inName );