summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@linbit.com>2011-02-15 11:23:44 +0100
committerAndreas Gruenbacher <agruen@linbit.com>2011-02-15 11:23:44 +0100
commitdcfb493578174ad9ac19bb748a2b196bed2099ce (patch)
tree51148a9d5f418fd1d33208afe64dc8b3bb3d1d52
parent3fc5b24073cbb0b650b7bfb4447101e424965c56 (diff)
downloadpatch-dcfb493578174ad9ac19bb748a2b196bed2099ce.tar.gz
Fix use of uninitialized outst
* src/patch.c (main): Fix use of initialized outst and add an additional assert. Reported by Jim Meyering.
-rw-r--r--ChangeLog5
-rw-r--r--src/patch.c7
2 files changed, 9 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index e72c82c..4fd8a9b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-02-15 Andreas Gruenbacher <agruen@linbit.com>
+
+ * src/patch.c (main): Fix use of initialized outst and add an
+ additional assert. Reported by Jim Meyering.
+
2011-02-03 Ozan Çağlayan <ozan@pardus.org.tr>
Create directory test case
diff --git a/src/patch.c b/src/patch.c
index 77be499..723a6e2 100644
--- a/src/patch.c
+++ b/src/patch.c
@@ -238,6 +238,7 @@ main (int argc, char **argv)
}
}
+ outst.st_size = -1;
outfd = make_tempfile (&TMPOUTNAME, 'o', outname,
O_WRONLY | binary_transput, instat.st_mode);
TMPOUTNAME_needs_removal = 1;
@@ -248,10 +249,9 @@ main (int argc, char **argv)
outstate.ofp);
if (! dry_run && ! outfile && ! skip_rest_of_patch)
{
- struct stat statbuf;
- if (fstat (outfd, &statbuf) != 0)
+ if (fstat (outfd, &outst) != 0)
pfatal ("%s", TMPOUTNAME);
- outstate.zero_output = statbuf.st_size == 0;
+ outstate.zero_output = outst.st_size == 0;
}
close (outfd);
outfd = -1;
@@ -500,6 +500,7 @@ main (int argc, char **argv)
set_file_attributes (TMPOUTNAME, attr, inname, &instat,
mode, &new_time);
+ assert (outst.st_size != -1);
move_file (TMPOUTNAME, &TMPOUTNAME_needs_removal, &outst,
outname, mode, backup);