Make ossl_namemap_name2num() return 0 when `name` is NULL, so callers can
use a single lookup path without local NULL guards.
Fixes: aec9e7fe1693 ("Allow core_namemap to limit hashtable key sizes")
Resolves: https://scan5.scan.coverity.com/#/project-view/65138/10222?selectedIssue=
1683247
Resolves: https://scan5.scan.coverity.com/#/project-view/65138/10222?selectedIssue=
1683248
Resolves: https://scan5.scan.coverity.com/#/project-view/65138/10222?selectedIssue=
1683249
Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Tue Mar 10 18:29:00 2026
(Merged from https://github.com/openssl/openssl/pull/30286)
(cherry picked from commit
b0ba5c81e43053ae0b8a6cb3559e54b7f6d025d9)
namemap = ossl_namemap_stored(NULL);
#endif
- if (namemap == NULL)
+ if (namemap == NULL || name == NULL)
return 0;
HT_INIT_RAW_KEY(&key);
return NULL;
}
- id = name != NULL ? ossl_namemap_name2num(namemap, name) : 0;
+ id = ossl_namemap_name2num(namemap, name);
/*
* If we haven't found the name yet, chances are that the algorithm to
}
/* If we haven't received a name id yet, try to get one for the name */
- name_id = name != NULL ? ossl_namemap_name2num(namemap, name) : 0;
+ name_id = ossl_namemap_name2num(namemap, name);
/*
* If we have a name id, calculate a method id with evp_method_id().
name_id = ossl_namemap_name2num(namemap, name);
if (name_id == 0) {
ERR_raise_data(ERR_LIB_EVP, ERR_R_FETCH_FAILED,
- "Algorithm %s cannot be found", name);
+ "Algorithm %s cannot be found", name != NULL ? name : "<null>");
free_method(method);
method = NULL;
} else {
}
/* If we haven't received a name id yet, try to get one for the name */
- id = scheme != NULL ? ossl_namemap_name2num(namemap, scheme) : 0;
+ id = ossl_namemap_name2num(namemap, scheme);
/*
* If we haven't found the name yet, chances are that the algorithm to