From: Pauli Date: Wed, 19 Aug 2020 03:57:00 +0000 (+1000) Subject: cmp: handle error return from OBJ_obj2txt() X-Git-Tag: openssl-3.0.0-alpha7~553 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3b1fd0b003572554ad9bb3914527c160bc6a7727;p=thirdparty%2Fopenssl.git cmp: handle error return from OBJ_obj2txt() Reviewed-by: Richard Levitte (Merged from https://github.com/openssl/openssl/pull/12678) --- diff --git a/apps/cmp.c b/apps/cmp.c index f0b31487140..b2afbf64e88 100644 --- a/apps/cmp.c +++ b/apps/cmp.c @@ -2241,7 +2241,7 @@ static void print_itavs(STACK_OF(OSSL_CMP_ITAV) *itavs) { OSSL_CMP_ITAV *itav = NULL; char buf[128]; - int i; + int i, r; int n = sk_OSSL_CMP_ITAV_num(itavs); /* itavs == NULL leads to 0 */ if (n == 0) { @@ -2251,8 +2251,13 @@ static void print_itavs(STACK_OF(OSSL_CMP_ITAV) *itavs) for (i = 0; i < n; i++) { itav = sk_OSSL_CMP_ITAV_value(itavs, i); - OBJ_obj2txt(buf, 128, OSSL_CMP_ITAV_get0_type(itav), 0); - CMP_info1("genp contains ITAV of type: %s", buf); + r = OBJ_obj2txt(buf, 128, OSSL_CMP_ITAV_get0_type(itav), 0); + if (r < 0) + CMP_err("could not get ITAV details"); + else if (r == 0) + CMP_info("genp contains empty ITAV"); + else + CMP_info1("genp contains ITAV of type: %s", buf); } }