From 7f163b682a57f42bd9b39a7f2d7e4c1c67df8386 Mon Sep 17 00:00:00 2001 From: Matus Fabian Date: Mon, 22 Jul 2024 09:56:01 +0200 Subject: misc: replace index() with strchr() Type: improvement Change-Id: I471e514ebef0b4c1f86067115b2ebe5a5517c6fb Signed-off-by: Matus Fabian --- src/svm/svmdb.c | 2 +- src/vat/api_format.c | 2 +- src/vlib/format.c | 2 +- src/vlib/main.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/svm/svmdb.c b/src/svm/svmdb.c index 3c69dbf45ba..98bb96f3dd4 100644 --- a/src/svm/svmdb.c +++ b/src/svm/svmdb.c @@ -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); diff --git a/src/vat/api_format.c b/src/vat/api_format.c index 45ba025f191..48c1ccaa820 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -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; diff --git a/src/vlib/format.c b/src/vlib/format.c index 7de6417be69..98010620a5d 100644 --- a/src/vlib/format.c +++ b/src/vlib/format.c @@ -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; diff --git a/src/vlib/main.c b/src/vlib/main.c index 04b58762646..8f87df997e5 100644 --- a/src/vlib/main.c +++ b/src/vlib/main.c @@ -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; -- cgit 1.2.3-korg