diff options
author | jsing <> | 2018-03-20 15:40:10 +0000 |
---|---|---|
committer | jsing <> | 2018-03-20 15:40:10 +0000 |
commit | b2caddc2ad6785096c5e0f5f75754bd79a0b2a66 (patch) | |
tree | f0421caa565cb68a4834a249d01c627c422fc93f | |
parent | e9dbc845b3107905fcd6f7ec35e52ad08e4826a1 (diff) | |
download | openbsd-b2caddc2ad6785096c5e0f5f75754bd79a0b2a66.tar.gz openbsd-b2caddc2ad6785096c5e0f5f75754bd79a0b2a66.tar.bz2 openbsd-b2caddc2ad6785096c5e0f5f75754bd79a0b2a66.zip |
Avoid potentially calling strchr() on a NULL pointer in
tls_config_set_ecdhecurve().
Spotted by Coverity.
-rw-r--r-- | src/lib/libtls/tls_config.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/lib/libtls/tls_config.c b/src/lib/libtls/tls_config.c index 02f2b3c6e9..d32176fe6e 100644 --- a/src/lib/libtls/tls_config.c +++ b/src/lib/libtls/tls_config.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls_config.c,v 1.50 2018/03/19 16:34:47 jsing Exp $ */ | 1 | /* $OpenBSD: tls_config.c,v 1.51 2018/03/20 15:40:10 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -517,17 +517,16 @@ tls_config_set_dheparams(struct tls_config *config, const char *params) | |||
517 | int | 517 | int |
518 | tls_config_set_ecdhecurve(struct tls_config *config, const char *curve) | 518 | tls_config_set_ecdhecurve(struct tls_config *config, const char *curve) |
519 | { | 519 | { |
520 | if (strchr(curve, ',') != NULL || strchr(curve, ':') != NULL) { | 520 | if (curve == NULL || |
521 | strcasecmp(curve, "none") == 0 || | ||
522 | strcasecmp(curve, "auto") == 0) { | ||
523 | curve = TLS_ECDHE_CURVES; | ||
524 | } else if (strchr(curve, ',') != NULL || strchr(curve, ':') != NULL) { | ||
521 | tls_config_set_errorx(config, "invalid ecdhe curve '%s'", | 525 | tls_config_set_errorx(config, "invalid ecdhe curve '%s'", |
522 | curve); | 526 | curve); |
523 | return (-1); | 527 | return (-1); |
524 | } | 528 | } |
525 | 529 | ||
526 | if (curve == NULL || | ||
527 | strcasecmp(curve, "none") == 0 || | ||
528 | strcasecmp(curve, "auto") == 0) | ||
529 | curve = TLS_ECDHE_CURVES; | ||
530 | |||
531 | return tls_config_set_ecdhecurves(config, curve); | 530 | return tls_config_set_ecdhecurves(config, curve); |
532 | } | 531 | } |
533 | 532 | ||