summaryrefslogtreecommitdiff
path: root/cmdline
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-11-15 12:26:39 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2010-11-15 12:26:39 +0100
commit4a6fe09cf2a7f18de2f80a1b79ea43e211302dbc (patch)
treefc2c11a9e13ce1de7dc62095865320be51a6e0d5 /cmdline
parenta4c404301df135bea81f23b944dc6e1967f9ca85 (diff)
use mkdtemp() instead of tempnam, free mkdtemp() data afterwards, return true in DoChangelog handler
Diffstat (limited to 'cmdline')
-rw-r--r--cmdline/apt-get.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 72c1ef0b0..0d67585a7 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -2773,11 +2773,18 @@ string DownloadChangelog(CacheFile &CacheFile, pkgAcquire &Fetcher, pkgCache::Ve
Fetcher.Setup(&Stat);
// temp file
- string targetfile = tmpnam(strdup("apt-changelog-XXXXXX"));
- new pkgAcqFile(&Fetcher, uri, "", 0, descr, srcpkg, "ignore", targetfile);
+ char *tmpdir = mkdtemp(strdup("apt-changelog-XXXXXX"));
+ if (tmpdir == NULL) {
+ _error->Errno("mkdtemp", "mkdtemp failed");
+ return "";
+ }
+ string targetfile = string(tmpdir) + "changelog";
// get it
+ new pkgAcqFile(&Fetcher, uri, "", 0, descr, srcpkg, tmpdir);
int res = Fetcher.Run();
+ free(tmpdir);
+
if (FileExists(targetfile))
return targetfile;
@@ -2826,9 +2833,12 @@ bool DoChangelog(CommandLine &CmdL)
if (changelogfile.size() > 0)
{
DisplayFileInPager(changelogfile);
+ // cleanup
unlink(changelogfile.c_str());
+ rmdir(flNotFile(changelogfile).c_str());
}
}
+ return true;
}
/*}}}*/
// DoMoo - Never Ask, Never Tell /*{{{*/