diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2018-03-20 15:40:11 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2018-03-20 15:40:11 +0000 |
commit | 1d6b51f805863eb722e8d1174b8790d6f97e1c0a (patch) | |
tree | f6865990e9619f93799c5b398882de107a7d8993 /lib | |
parent | 3ee1ae95af6d4889b2905c75700a07eb8c3e1df5 (diff) |
Avoid potentially calling strchr() on a NULL pointer in
tls_config_set_ecdhecurve().
Spotted by Coverity.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libtls/tls_config.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/libtls/tls_config.c b/lib/libtls/tls_config.c index 02f2b3c6e92..d32176fe6e1 100644 --- a/lib/libtls/tls_config.c +++ b/lib/libtls/tls_config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls_config.c,v 1.50 2018/03/19 16:34:47 jsing Exp $ */ +/* $OpenBSD: tls_config.c,v 1.51 2018/03/20 15:40:10 jsing Exp $ */ /* * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> * @@ -517,17 +517,16 @@ tls_config_set_dheparams(struct tls_config *config, const char *params) int tls_config_set_ecdhecurve(struct tls_config *config, const char *curve) { - if (strchr(curve, ',') != NULL || strchr(curve, ':') != NULL) { + if (curve == NULL || + strcasecmp(curve, "none") == 0 || + strcasecmp(curve, "auto") == 0) { + curve = TLS_ECDHE_CURVES; + } else if (strchr(curve, ',') != NULL || strchr(curve, ':') != NULL) { tls_config_set_errorx(config, "invalid ecdhe curve '%s'", curve); return (-1); } - if (curve == NULL || - strcasecmp(curve, "none") == 0 || - strcasecmp(curve, "auto") == 0) - curve = TLS_ECDHE_CURVES; - return tls_config_set_ecdhecurves(config, curve); } |