From 07bef4c29af7c18ac9a973f7e92cf27c346fd771 Mon Sep 17 00:00:00 2001 From: doug <> Date: Mon, 20 Jul 2015 17:10:45 +0000 Subject: Avoid dereferencing a NULL. Move NULL check before use. Fixes Coverity issue 21746. ok miod@ jsing@ --- src/usr.bin/openssl/dgst.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/usr.bin/openssl/dgst.c b/src/usr.bin/openssl/dgst.c index ab64af9192..655b2083d0 100644 --- a/src/usr.bin/openssl/dgst.c +++ b/src/usr.bin/openssl/dgst.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dgst.c,v 1.1 2014/08/26 17:47:24 jsing Exp $ */ +/* $OpenBSD: dgst.c,v 1.2 2015/07/20 17:10:45 doug Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -254,8 +254,14 @@ dgst_main(int argc, char **argv) EVP_MD_do_all_sorted(list_md_fn, bio_err); goto end; } + in = BIO_new(BIO_s_file()); bmd = BIO_new(BIO_f_md()); + if (in == NULL || bmd == NULL) { + ERR_print_errors(bio_err); + goto end; + } + if (debug) { BIO_set_callback(in, BIO_debug_callback); /* needed for windows 3.1 */ @@ -265,10 +271,6 @@ dgst_main(int argc, char **argv) BIO_printf(bio_err, "Error getting password\n"); goto end; } - if ((in == NULL) || (bmd == NULL)) { - ERR_print_errors(bio_err); - goto end; - } if (out_bin == -1) { if (keyfile) out_bin = 1; -- cgit v1.2.3-55-g6feb