From 9ea0404651639f960ab3899776a5362ec7b2a181 Mon Sep 17 00:00:00 2001 From: "alexei.volkov.bugs%sun.com" Date: Mon, 17 Jul 2006 22:08:03 +0000 Subject: [PATCH] 341291: Coverity 689 - potential NULL ptr crash in ssl3_SendCertificate. r=nelson --- security/nss/lib/ssl/ssl3con.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/security/nss/lib/ssl/ssl3con.c b/security/nss/lib/ssl/ssl3con.c index 1562b3b04ce0..32908583d80f 100644 --- a/security/nss/lib/ssl/ssl3con.c +++ b/security/nss/lib/ssl/ssl3con.c @@ -39,7 +39,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/* $Id: ssl3con.c,v 1.92 2006/06/26 23:32:19 wtchang%redhat.com Exp $ */ +/* $Id: ssl3con.c,v 1.93 2006/07/17 22:08:03 alexei.volkov.bugs%sun.com Exp $ */ #include "nssrenam.h" #include "cert.h" @@ -6783,23 +6783,25 @@ ssl3_SendCertificate(sslSocket *ss) if (rv != SECSuccess) { return rv; /* err set by AppendHandshake. */ } - for (i = 0; i < certChain->len; i++) { + if (certChain) { + for (i = 0; i < certChain->len; i++) { #ifdef NISCC_TEST - if (fakeCert.len > 0 && i == ndex) { - rv = ssl3_AppendHandshakeVariable(ss, fakeCert.data, fakeCert.len, - 3); - SECITEM_FreeItem(&fakeCert, PR_FALSE); - } else { - rv = ssl3_AppendHandshakeVariable(ss, certChain->certs[i].data, - certChain->certs[i].len, 3); - } + if (fakeCert.len > 0 && i == ndex) { + rv = ssl3_AppendHandshakeVariable(ss, fakeCert.data, + fakeCert.len, 3); + SECITEM_FreeItem(&fakeCert, PR_FALSE); + } else { + rv = ssl3_AppendHandshakeVariable(ss, certChain->certs[i].data, + certChain->certs[i].len, 3); + } #else - rv = ssl3_AppendHandshakeVariable(ss, certChain->certs[i].data, - certChain->certs[i].len, 3); + rv = ssl3_AppendHandshakeVariable(ss, certChain->certs[i].data, + certChain->certs[i].len, 3); #endif - if (rv != SECSuccess) { - return rv; /* err set by AppendHandshake. */ - } + if (rv != SECSuccess) { + return rv; /* err set by AppendHandshake. */ + } + } } return SECSuccess;