Blame SOURCES/jss-fix-PK11Store-getEncryptedPrivateKeyInfo-segfault.patch

762105
# HG changeset patch
762105
# User Fraser Tweedale<ftweedale@redhat.com>
762105
# Date 1505175862 25200
762105
#      Mon Sep 11 17:24:22 2017 -0700
762105
# Node ID 3e9a5ae2149d04877dc19b117a8917c22854f8eb
762105
# Parent  87dca07f7529463398734d1279bcfd7023a43d4c
762105
Bug 1371147 PK11Store.getEncryptedPrivateKeyInfo() segfault if export fails -
762105
patch jss-ftweedal-0011-Don-t-crash-if-PK11_ExportEncryptedPrivKeyInfo-retur.patch
762105
Subject: Don't crash if PK11_ExportEncryptedPrivKeyInfo returns NULL
762105
From: Fraser Tweedale <ftweedal@redhat.com>
762105
Content-Type: text/plain
762105
found patch at byte 239
762105
message:
762105
Don't crash if PK11_ExportEncryptedPrivKeyInfo returns NULL
762105
PK11_ExportEncryptedPrivKeyInfo returning NULL is not being handled
762105
properly, causing segfault.  Detect this condition and raise a
762105
TokenException instead.
762105
762105
cfu for ftweedal
762105
762105
diff -r 87dca07f7529 -r 3e9a5ae2149d org/mozilla/jss/pkcs11/PK11Store.c
762105
--- a/org/mozilla/jss/pkcs11/PK11Store.c	Fri Sep 08 11:56:04 2017 -0700
762105
+++ b/org/mozilla/jss/pkcs11/PK11Store.c	Mon Sep 11 17:24:22 2017 -0700
762105
@@ -581,6 +581,11 @@
762105
     // export the epki
762105
     epki = PK11_ExportEncryptedPrivKeyInfo(
762105
         slot, algTag, pwItem, privk, iterations, NULL /*wincx*/);
762105
+    if (epki == NULL) {
762105
+        JSS_throwMsgPrErr(
762105
+            env, TOKEN_EXCEPTION, "Failed to export EncryptedPrivateKeyInfo");
762105
+        goto finish;
762105
+    }
762105
 
762105
     // DER-encode the epki
762105
     if (SEC_ASN1EncodeItem(NULL, &epkiItem, epki,