From 0f644b96d209443b4566f7e86e3be2568292e75b Mon Sep 17 00:00:00 2001 From: rilysh Date: Sun, 21 Jan 2024 12:18:09 +0530 Subject: [PATCH] replace strstr() with strchr() for single characters strstr() is used to match multiple characters in the haystack, whereas strchr() is used to matched only single character. CLA: trivial Reviewed-by: Tom Cosgrove Reviewed-by: Matt Caswell Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/23347) --- apps/engine.c | 2 +- crypto/dso/dso_dl.c | 2 +- crypto/dso/dso_dlfcn.c | 2 +- ssl/ssl_conf.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/engine.c b/apps/engine.c index dc57dc746546c..35d0368b3a055 100644 --- a/apps/engine.c +++ b/apps/engine.c @@ -251,7 +251,7 @@ static void util_do_cmds(ENGINE *e, STACK_OF(OPENSSL_STRING) *cmds, cmd = sk_OPENSSL_STRING_value(cmds, loop); res = 1; /* assume success */ /* Check if this command has no ":arg" */ - if ((arg = strstr(cmd, ":")) == NULL) { + if ((arg = strchr(cmd, ':')) == NULL) { if (!ENGINE_ctrl_cmd_string(e, cmd, NULL, 0)) res = 0; } else { diff --git a/crypto/dso/dso_dl.c b/crypto/dso/dso_dl.c index ac942548077f4..a2ec5c77f3144 100644 --- a/crypto/dso/dso_dl.c +++ b/crypto/dso/dso_dl.c @@ -217,7 +217,7 @@ static char *dl_name_converter(DSO *dso, const char *filename) len = strlen(filename); rsize = len + 1; - transform = (strstr(filename, "/") == NULL); + transform = (strchr(filename, '/') == NULL); if (transform) { /* We will convert this to "%s.s?" or "lib%s.s?" */ rsize += strlen(DSO_EXTENSION); /* The length of ".s?" */ diff --git a/crypto/dso/dso_dlfcn.c b/crypto/dso/dso_dlfcn.c index 2befd672485ce..e128b4cc03d2f 100644 --- a/crypto/dso/dso_dlfcn.c +++ b/crypto/dso/dso_dlfcn.c @@ -251,7 +251,7 @@ static char *dlfcn_name_converter(DSO *dso, const char *filename) len = strlen(filename); rsize = len + 1; - transform = (strstr(filename, "/") == NULL); + transform = (strchr(filename, '/') == NULL); if (transform) { /* We will convert this to "%s.so" or "lib%s.so" etc */ rsize += strlen(DSO_EXTENSION); /* The length of ".so" */ diff --git a/ssl/ssl_conf.c b/ssl/ssl_conf.c index 49e682247929b..e8d319bc52293 100644 --- a/ssl/ssl_conf.c +++ b/ssl/ssl_conf.c @@ -241,7 +241,7 @@ static int cmd_ECDHParameters(SSL_CONF_CTX *cctx, const char *value) return 1; /* ECDHParameters accepts a single group name */ - if (strstr(value, ":") != NULL) + if (strchr(value, ':') != NULL) return 0; if (cctx->ctx)