summaryrefslogtreecommitdiffstats
path: root/src/vlib/format.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vlib/format.c')
-rw-r--r--src/vlib/format.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/vlib/format.c b/src/vlib/format.c
index 79a4d6866db..ee730bd1c28 100644
--- a/src/vlib/format.c
+++ b/src/vlib/format.c
@@ -187,6 +187,30 @@ done:
return p != 0;
}
+/* Parse a filename to dump debug info */
+uword
+unformat_vlib_tmpfile (unformat_input_t * input, va_list * args)
+{
+ u8 **chroot_filename = va_arg (*args, u8 **);
+ u8 *filename;
+
+ if (!unformat (input, "%s", &filename))
+ return 0;
+
+ /* Brain-police user path input */
+ if (strstr ((char *) filename, "..") || index ((char *) filename, '/'))
+ {
+ vec_free (filename);
+ return 0;
+ }
+
+ *chroot_filename = format (0, "/tmp/%s%c", filename, 0);
+ vec_free (filename);
+
+ return 1;
+}
+
+
/*
* fd.io coding-style-patch-verification: ON
*