alexk / rpms / rpm

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