richardphibel / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
b7b7cd
--- rpm-4.11.1/lib/fsm.c.orig	2014-11-13 13:38:56.742934031 +0100
b7b7cd
+++ rpm-4.11.1/lib/fsm.c	2014-11-13 13:42:13.036380024 +0100
b7b7cd
@@ -726,12 +726,17 @@
b7b7cd
 {
b7b7cd
     FD_t wfd = NULL;
b7b7cd
     const struct stat * st = &fsm->sb;
b7b7cd
-    rpm_loff_t left = st->st_size;
b7b7cd
+    rpm_loff_t left = rpmfiFSizeIndex(fsmGetFi(fsm), fsm->ix);
b7b7cd
     const unsigned char * fidigest = NULL;
b7b7cd
     pgpHashAlgo digestalgo = 0;
b7b7cd
     int rc = 0;
b7b7cd
 
b7b7cd
-    wfd = Fopen(fsm->path, "w.ufdio");
b7b7cd
+    /* Create the file with 000 permissions. */
b7b7cd
+    {
b7b7cd
+	mode_t old_umask = umask(0777);
b7b7cd
+	wfd = Fopen(fsm->path, "w.ufdio");
b7b7cd
+	umask(old_umask);
b7b7cd
+    }                      
b7b7cd
     if (Ferror(wfd)) {
b7b7cd
 	rc = CPIOERR_OPEN_FAILED;
b7b7cd
 	goto exit;