From 41c028be1988ad160ef2fa6feca4441bb4bca17d Mon Sep 17 00:00:00 2001 From: miod <> Date: Tue, 28 Oct 2014 05:46:56 +0000 Subject: Check the result of sk_*_push() operations for failure. ok doug@ jsing@ --- src/lib/libcrypto/asn1/a_strnid.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/lib/libcrypto/asn1') diff --git a/src/lib/libcrypto/asn1/a_strnid.c b/src/lib/libcrypto/asn1/a_strnid.c index be28885363..4da45c537e 100644 --- a/src/lib/libcrypto/asn1/a_strnid.c +++ b/src/lib/libcrypto/asn1/a_strnid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_strnid.c,v 1.17 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: a_strnid.c,v 1.18 2014/10/28 05:46:55 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -261,8 +261,14 @@ ASN1_STRING_TABLE_add(int nid, long minsize, long maxsize, unsigned long mask, if (maxsize != -1) tmp->maxsize = maxsize; tmp->mask = mask; - if (new_nid) - sk_ASN1_STRING_TABLE_push(stable, tmp); + if (new_nid) { + if (sk_ASN1_STRING_TABLE_push(stable, tmp) == 0) { + free(tmp); + ASN1err(ASN1_F_ASN1_STRING_TABLE_ADD, + ERR_R_MALLOC_FAILURE); + return 0; + } + } return 1; } -- cgit v1.2.3-55-g6feb