Skip to content

Commit

Permalink
replace strstr() with strchr() for single characters
Browse files Browse the repository at this point in the history
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 <tom.cosgrove@arm.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #23347)
  • Loading branch information
rilysh authored and t8m committed Jan 25, 2024
1 parent ea6268c commit 0f644b9
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion crypto/dso/dso_dl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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?" */
Expand Down
2 changes: 1 addition & 1 deletion crypto/dso/dso_dlfcn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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" */
Expand Down
2 changes: 1 addition & 1 deletion ssl/ssl_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0f644b9

Please sign in to comment.