From: guenther Date: Wed, 6 Aug 2014 04:28:21 +0000 (+0000) Subject: Correct error checks in EVP_read_pw_string_min(): UI_add_input_string() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=b60d353a6574f98e3f5a376ed21afd96d064e654;p=openbsd Correct error checks in EVP_read_pw_string_min(): UI_add_input_string() and UI_add_verify_string() return -1 (and maybe -2?) on failure and >=0 on success, instead of always zero on success problem reported by Mark Patruck (mark (at) wrapped.cx) ok miod@ --- diff --git a/lib/libcrypto/evp/evp_key.c b/lib/libcrypto/evp/evp_key.c index 2873a888bd2..1493ca91036 100644 --- a/lib/libcrypto/evp/evp_key.c +++ b/lib/libcrypto/evp/evp_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_key.c,v 1.19 2014/07/23 04:44:56 miod Exp $ */ +/* $OpenBSD: evp_key.c,v 1.20 2014/08/06 04:28:21 guenther Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -106,11 +106,11 @@ EVP_read_pw_string_min(char *buf, int min, int len, const char *prompt, if (ui == NULL) return -1; if (UI_add_input_string(ui, prompt, 0, buf, min, - (len >= BUFSIZ) ? BUFSIZ - 1 : len) != 0) + (len >= BUFSIZ) ? BUFSIZ - 1 : len) < 0) return -1; if (verify) { if (UI_add_verify_string(ui, prompt, 0, buff, min, - (len >= BUFSIZ) ? BUFSIZ - 1 : len, buf) != 0) + (len >= BUFSIZ) ? BUFSIZ - 1 : len, buf) < 0) return -1; } ret = UI_process(ui); diff --git a/lib/libssl/src/crypto/evp/evp_key.c b/lib/libssl/src/crypto/evp/evp_key.c index 2873a888bd2..1493ca91036 100644 --- a/lib/libssl/src/crypto/evp/evp_key.c +++ b/lib/libssl/src/crypto/evp/evp_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_key.c,v 1.19 2014/07/23 04:44:56 miod Exp $ */ +/* $OpenBSD: evp_key.c,v 1.20 2014/08/06 04:28:21 guenther Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -106,11 +106,11 @@ EVP_read_pw_string_min(char *buf, int min, int len, const char *prompt, if (ui == NULL) return -1; if (UI_add_input_string(ui, prompt, 0, buf, min, - (len >= BUFSIZ) ? BUFSIZ - 1 : len) != 0) + (len >= BUFSIZ) ? BUFSIZ - 1 : len) < 0) return -1; if (verify) { if (UI_add_verify_string(ui, prompt, 0, buff, min, - (len >= BUFSIZ) ? BUFSIZ - 1 : len, buf) != 0) + (len >= BUFSIZ) ? BUFSIZ - 1 : len, buf) < 0) return -1; } ret = UI_process(ui);