X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvlib%2Fformat.c;h=ee730bd1c28c62a10e33c9345b4fb60e0554f5de;hb=refs%2Fchanges%2F18%2F18518%2F3;hp=79a4d6866db9d2f1a647b4ce771c2ec6b9a1ec4b;hpb=7cd468a3d7dee7d6c92f69a0bb7061ae208ec727;p=vpp.git 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 *