285d04
diff -up ./lib/pkcs12/p12local.c.fix_null_password ./lib/pkcs12/p12local.c
285d04
--- ./lib/pkcs12/p12local.c.fix_null_password	2022-07-20 14:15:45.081009438 -0700
285d04
+++ ./lib/pkcs12/p12local.c	2022-07-20 14:19:40.856546963 -0700
285d04
@@ -968,15 +968,14 @@ sec_pkcs12_convert_item_to_unicode(PLAre
285d04
     if (zeroTerm) {
285d04
         /* unicode adds two nulls at the end */
285d04
         if (toUnicode) {
285d04
-            if ((dest->len >= 2) &&
285d04
-                (dest->data[dest->len - 1] || dest->data[dest->len - 2])) {
285d04
+            if ((dest->len < 2) || dest->data[dest->len - 1] || dest->data[dest->len - 2]) {
285d04
                 /* we've already allocated space for these new NULLs */
285d04
                 PORT_Assert(dest->len + 2 <= bufferSize);
285d04
                 dest->len += 2;
285d04
                 dest->data[dest->len - 1] = dest->data[dest->len - 2] = 0;
285d04
             }
285d04
             /* ascii/utf-8 adds just 1 */
285d04
-        } else if ((dest->len >= 1) && dest->data[dest->len - 1]) {
285d04
+        } else if (!dest->len || dest->data[dest->len - 1]) {
285d04
             PORT_Assert(dest->len + 1 <= bufferSize);
285d04
             dest->len++;
285d04
             dest->data[dest->len - 1] = 0;