]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
gen_path will no longer silently truncate the generated
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Fri, 18 Jul 2008 00:55:59 +0000 (00:55 +0000)
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Fri, 18 Jul 2008 00:55:59 +0000 (00:55 +0000)
filename at 256 bytes.

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

init.c
misc.c

diff --git a/init.c b/init.c
index 05d8cd771ba3b99913f1c4c1da7a143f0f78629b..218fae1919f920c4b1c64dd8badb5cfcdcc6d134 100644 (file)
--- a/init.c
+++ b/init.c
@@ -439,6 +439,19 @@ init_static (void)
   return false;
 #endif
 
+#if 0
+  {
+    struct gc_arena gc = gc_new ();
+    const char *fn = gen_path ("foo",
+                              "bar",
+                              &gc);
+    printf ("%s\n", fn);
+    gc_free (&gc);
+  }
+
+  return false;
+#endif
+
   return true;
 }
 
diff --git a/misc.c b/misc.c
index 97e80496749e976de83ac2fd9bab7a17a4aaf1de..901e8cb353d0880d1c8d1d4154d1c06b31bf8046 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -1129,7 +1129,8 @@ gen_path (const char *directory, const char *filename, struct gc_arena *gc)
 #endif
       )
     {
-      struct buffer out = alloc_buf_gc (256, gc);
+      const size_t outsize = strlen(safe_filename) + (directory ? strlen (directory) : 0) + 16;
+      struct buffer out = alloc_buf_gc (outsize, gc);
       char dirsep[2];
 
       dirsep[0] = OS_SPECIFIC_DIRSEP;