misc: replace index() with strchr() 83/41283/2
authorMatus Fabian <[email protected]>
Mon, 22 Jul 2024 07:56:01 +0000 (09:56 +0200)
committerFlorin Coras <[email protected]>
Mon, 22 Jul 2024 17:07:02 +0000 (17:07 +0000)
Type: improvement
Change-Id: I471e514ebef0b4c1f86067115b2ebe5a5517c6fb
Signed-off-by: Matus Fabian <[email protected]>
src/svm/svmdb.c
src/vat/api_format.c
src/vlib/format.c
src/vlib/main.c

index 3c69dbf..98bb96f 100644 (file)
@@ -436,7 +436,7 @@ svmdb_local_serialize_strings (svmdb_client_t * client, char *filename)
   u8 *sanitized_name = 0;
   int fd = 0;
 
-  if (strstr (filename, "..") || index (filename, '/'))
+  if (strstr (filename, "..") || strchr (filename, '/'))
     {
       error = clib_error_return (0, "Illegal characters in filename '%s'",
                                 filename);
index 45ba025..48c1cca 100644 (file)
@@ -2151,7 +2151,7 @@ elog_save (vat_main_t * vam)
     }
 
   /* It's fairly hard to get "../oopsie" through unformat; just in case */
-  if (strstr (file, "..") || index (file, '/'))
+  if (strstr (file, "..") || strchr (file, '/'))
     {
       errmsg ("illegal characters in filename '%s'", file);
       return 0;
index 7de6417..9801062 100644 (file)
@@ -198,7 +198,7 @@ unformat_vlib_tmpfile (unformat_input_t * input, va_list * args)
     return 0;
 
   /* Brain-police user path input */
-  if (strstr ((char *) filename, "..") || index ((char *) filename, '/'))
+  if (strstr ((char *) filename, "..") || strchr ((char *) filename, '/'))
     {
       vec_free (filename);
       return 0;
index 04b5876..8f87df9 100644 (file)
@@ -655,7 +655,7 @@ elog_save_buffer (vlib_main_t * vm,
     }
 
   /* It's fairly hard to get "../oopsie" through unformat; just in case */
-  if (strstr (file, "..") || index (file, '/'))
+  if (strstr (file, "..") || strchr (file, '/'))
     {
       vlib_cli_output (vm, "illegal characters in filename '%s'", file);
       return 0;