Просмотр исходного кода

apt-pkg/contrib/gpgv.cc: use /tmp as fallback dir

if the directory given by $TMPDIR is not available, use /tmp as fallback.
Thomas Bechtold лет назад: 12
Родитель
Сommit
38beb8b593
1 измененных файлов с 6 добавлено и 1 удалено
  1. 6 1
      apt-pkg/contrib/gpgv.cc

+ 6 - 1
apt-pkg/contrib/gpgv.cc

@@ -10,6 +10,7 @@
 #include <sys/stat.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <sys/wait.h>
+#include <unistd.h>
 
 
 #include<apt-pkg/configuration.h>
 #include<apt-pkg/configuration.h>
 #include<apt-pkg/error.h>
 #include<apt-pkg/error.h>
@@ -22,11 +23,15 @@
 static char * GenerateTemporaryFileTemplate(const char *basename)	/*{{{*/
 static char * GenerateTemporaryFileTemplate(const char *basename)	/*{{{*/
 {
 {
    const char *tmpdir = getenv("TMPDIR");
    const char *tmpdir = getenv("TMPDIR");
+
 #ifdef P_tmpdir
 #ifdef P_tmpdir
    if (!tmpdir)
    if (!tmpdir)
       tmpdir = P_tmpdir;
       tmpdir = P_tmpdir;
 #endif
 #endif
-   if (!tmpdir)
+
+   // check that tmpdir is set and exists
+   struct stat st;
+   if (!tmpdir || stat(tmpdir, &st) != 0)
       tmpdir = "/tmp";
       tmpdir = "/tmp";
 
 
    std::string out;
    std::string out;