File unpackmode0.diff of Package rpm.2971
--- ./lib/fsm.c.orig 2013-06-10 15:55:10.000000000 +0000
+++ ./lib/fsm.c 2014-12-11 14:56:46.948898563 +0000
@@ -726,12 +726,18 @@ static int expandRegular(FSM_t fsm, rpmp
{
FD_t wfd = NULL;
const struct stat * st = &fsm->sb;
- rpm_loff_t left = st->st_size;
+ rpm_loff_t size = rpmfiFSizeIndex(fsmGetFi(fsm), fsm->ix);
+ rpm_loff_t left = size;
const unsigned char * fidigest = NULL;
pgpHashAlgo digestalgo = 0;
int rc = 0;
- wfd = Fopen(fsm->path, "w.ufdio");
+ /* Create the file with 000 permissions. */
+ {
+ mode_t old_umask = umask(0777);
+ wfd = Fopen(fsm->path, "w.ufdio");
+ umask(old_umask);
+ }
if (Ferror(wfd)) {
rc = CPIOERR_OPEN_FAILED;
goto exit;
@@ -743,7 +749,7 @@ static int expandRegular(FSM_t fsm, rpmp
fidigest = rpmfiFDigestIndex(fi, fsm->ix, NULL, NULL);
}
- if (st->st_size > 0 && fidigest)
+ if (size > 0 && fidigest)
fdInitDigest(wfd, digestalgo, 0);
while (left) {
@@ -765,7 +771,7 @@ static int expandRegular(FSM_t fsm, rpmp
rpmpsmNotify(psm, RPMCALLBACK_INST_PROGRESS, rpmcpioTell(archive));
}
- if (st->st_size > 0 && fidigest) {
+ if (size > 0 && fidigest) {
void * digest = NULL;
(void) Fflush(wfd);