Browse code

gen_path will no longer silently truncate the generated filename at 256 bytes.

git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@3076 e7ae566f-a301-0410-adde-c780ea21d3b5

james authored on 2008/07/18 09:55:59
Showing 2 changed files
... ...
@@ -439,6 +439,19 @@ init_static (void)
439 439
   return false;
440 440
 #endif
441 441
 
442
+#if 0
443
+  {
444
+    struct gc_arena gc = gc_new ();
445
+    const char *fn = gen_path ("foo",
446
+			       "bar",
447
+			       &gc);
448
+    printf ("%s\n", fn);
449
+    gc_free (&gc);
450
+  }
451
+
452
+  return false;
453
+#endif
454
+
442 455
   return true;
443 456
 }
444 457
 
... ...
@@ -1129,7 +1129,8 @@ gen_path (const char *directory, const char *filename, struct gc_arena *gc)
1129 1129
 #endif
1130 1130
       )
1131 1131
     {
1132
-      struct buffer out = alloc_buf_gc (256, gc);
1132
+      const size_t outsize = strlen(safe_filename) + (directory ? strlen (directory) : 0) + 16;
1133
+      struct buffer out = alloc_buf_gc (outsize, gc);
1133 1134
       char dirsep[2];
1134 1135
 
1135 1136
       dirsep[0] = OS_SPECIFIC_DIRSEP;