]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
When making a tempdir for windows unit tests, avoid an extra backslash
authorNick Mathewson <nickm@torproject.org>
Wed, 16 Jul 2014 09:31:22 +0000 (11:31 +0200)
committerNick Mathewson <nickm@torproject.org>
Wed, 16 Jul 2014 09:39:03 +0000 (11:39 +0200)
The extra \ is harmless, but mildly unpleasant.

Fixes 12392; bugfix on 0.2.2.25-alpha where we started using
GetTempDir().  Based on a patch by Gisle Vanem.

src/test/test.c

index 8bce9c91f47203a5770904ccb5c95eba88eb180f..429e79ccdc9c255ff9a7b5b786c0b6dd3d40ae65 100644 (file)
@@ -106,11 +106,18 @@ setup_directory(void)
   {
     char buf[MAX_PATH];
     const char *tmp = buf;
+    const char *extra_backslash = "";
     /* If this fails, we're probably screwed anyway */
     if (!GetTempPathA(sizeof(buf),buf))
-      tmp = "c:\\windows\\temp";
+      tmp = "c:\\windows\\temp\\";
+    if (strcmpend(tmp, "\\")) {
+      /* According to MSDN, it should be impossible for GetTempPath to give us
+       * an answer that doesn't end with \.  But let's make sure. */
+      extra_backslash = "\\";
+    }
     tor_snprintf(temp_dir, sizeof(temp_dir),
-                 "%s\\tor_test_%d_%s", tmp, (int)getpid(), rnd32);
+                 "%s%stor_test_%d_%s", tmp, extra_backslash,
+                 (int)getpid(), rnd32);
     r = mkdir(temp_dir);
   }
 #else