From bcb3e86e311b0b810d7e635d41c44ff80aff8deb Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Fri, 16 Apr 2010 08:23:03 +0000 Subject: [PATCH] BZ #582781 Randomize name for files created in /tmp --- gource-predictable-tmp-filename.patch | 80 +++++++++++++++++++++++++++ gource.spec | 9 ++- 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 gource-predictable-tmp-filename.patch diff --git a/gource-predictable-tmp-filename.patch b/gource-predictable-tmp-filename.patch new file mode 100644 index 0000000..ba5e33f --- /dev/null +++ b/gource-predictable-tmp-filename.patch @@ -0,0 +1,80 @@ +From 5aa2c8adfbe0ec3e5d802bfae8e5572562d911c7 Mon Sep 17 00:00:00 2001 +From: Andrew Caudwell +Date: Thu, 15 Apr 2010 23:26:19 +0000 +Subject: [PATCH] Create temp file using mkstemp. + +--- + src/commitlog.cpp | 29 +++++++++++++++-------------- + src/commitlog.h | 2 +- + 2 files changed, 16 insertions(+), 15 deletions(-) + +diff --git a/src/commitlog.cpp b/src/commitlog.cpp +index 689a100..87171d5 100644 +--- a/src/commitlog.cpp ++++ b/src/commitlog.cpp +@@ -206,34 +206,35 @@ bool RCommitLog::isFinished() { + return false; + } + +-std::string RCommitLog::createTempLog() { +- //create temp file +- char logfile_buff[1024]; ++//create temp file ++void RCommitLog::createTempLog() { ++ ++ std::string tempdir; + + #ifdef _WIN32 + DWORD tmplen = GetTempPath(0, ""); + +- if(tmplen == 0) return 0; ++ if(tmplen == 0) return; + + std::vector temp(tmplen+1); + + tmplen = GetTempPath(static_cast(temp.size()), &temp[0]); + +- if(tmplen == 0 || tmplen >= temp.size()) return 0; +- +- std::string temp_file_path(temp.begin(), +- temp.begin() + static_cast(tmplen)); ++ if(tmplen == 0 || tmplen >= temp.size()) return; + +- temp_file_path += "gource.tmp"; ++ std::string tempdir = std::string(temp.begin(), temp.begin() + static_cast(tmplen)); ++ tempdir += "\\"; + +- sprintf(logfile_buff, "%s", temp_file_path.c_str()); + #else +- uid_t myuid = getuid(); +- sprintf(logfile_buff, "/tmp/gource-%d.tmp", myuid); ++ tempdir = "/tmp/"; + #endif +- temp_file = std::string(logfile_buff); + +- return temp_file; ++ char tmplate[1024]; ++ snprintf(tmplate, 1024, "%sgource-XXXXXX", tempdir.c_str()); ++ ++ if(mkstemp(tmplate) < 0) return; ++ ++ temp_file = std::string(tmplate); + } + + // RCommitFile +diff --git a/src/commitlog.h b/src/commitlog.h +index 1867396..5ff8da2 100644 +--- a/src/commitlog.h ++++ b/src/commitlog.h +@@ -77,7 +77,7 @@ protected: + + bool checkFirstChar(int firstChar, std::istream& stream); + +- std::string createTempLog(); ++ void createTempLog(); + + bool getNextLine(std::string& line); + +-- +1.6.5 + diff --git a/gource.spec b/gource.spec index cbe2e41..49e1200 100644 --- a/gource.spec +++ b/gource.spec @@ -3,7 +3,7 @@ Summary: Software version control visualization Name: gource Version: 0.24 -Release: 2%{?dist} +Release: 3%{?dist} URL: http://gource.googlecode.com/ Source: http://gource.googlecode.com/files/%{name}-%{version}.tar.gz @@ -27,6 +27,9 @@ Requires: gnu-free-sans-fonts # https://bugzilla.redhat.com/show_bug.cgi?id=567559 Patch0: gource-ppm-software-flip.patch +# https://bugzilla.redhat.com/show_bug.cgi?id=582781 +Patch1: gource-predictable-tmp-filename.patch + %description OpenGL-based 3D visualisation tool for source control repositories. @@ -40,6 +43,7 @@ files and directories. sed -i.cp -e 's|cp |cp -p |' Makefile.in %patch0 -p1 -b .ppm-software-flip +%patch1 -p1 -b .predictable-tmp-filename %build %configure --enable-ttf-font-dir=%{_datadir}/fonts/gnu-free/ @@ -64,6 +68,9 @@ rm -rf %{buildroot} %{_datadir}/gource/* %changelog +* Fri Apr 16 2010 Siddhesh Poyarekar - 0.24-3 +- BZ #582781 Randomize name for files created in /tmp + * Sun Feb 28 2010 Siddhesh Poyarekar - 0.24-2 - BZ #567559: Flip images in software for PPM output since hardware flipping fails on some video cards