Blame SOURCES/pem-compile-with-Werror.patch

1b6f66
diff -up ./nss/lib/ckfw/pem/ckpem.h.compile_Werror ./nss/lib/ckfw/pem/ckpem.h
1b6f66
--- ./nss/lib/ckfw/pem/ckpem.h.compile_Werror	2014-01-23 06:28:18.000000000 -0800
1b6f66
+++ ./nss/lib/ckfw/pem/ckpem.h	2015-11-13 12:07:29.219887390 -0800
1b6f66
@@ -233,6 +233,9 @@ struct pemLOWKEYPrivateKeyStr {
1b6f66
 };
1b6f66
 typedef struct pemLOWKEYPrivateKeyStr pemLOWKEYPrivateKey;
1b6f66
 
1b6f66
+/* NOTE: Discrepancy with the the way callers use of the return value as a count
1b6f66
+ * Fix this when we sync. up with the cleanup work being done at nss-pem project.
1b6f66
+ */
1b6f66
 SECStatus ReadDERFromFile(SECItem ***derlist, char *filename, PRBool ascii, int *cipher, char **ivstring, PRBool certsonly);
1b6f66
 const NSSItem * pem_FetchAttribute ( pemInternalObject *io, CK_ATTRIBUTE_TYPE type);
1b6f66
 void pem_PopulateModulusExponent(pemInternalObject *io);
1b6f66
diff -up ./nss/lib/ckfw/pem/pinst.c.compile_Werror ./nss/lib/ckfw/pem/pinst.c
1b6f66
--- ./nss/lib/ckfw/pem/pinst.c.compile_Werror	2014-01-23 06:28:18.000000000 -0800
1b6f66
+++ ./nss/lib/ckfw/pem/pinst.c	2015-11-13 12:07:29.219887390 -0800
1b6f66
@@ -472,7 +472,9 @@ AddCertificate(char *certfile, char *key
1b6f66
     char *ivstring = NULL;
1b6f66
     int cipher;
1b6f66
 
1b6f66
-    nobjs = ReadDERFromFile(&objs, certfile, PR_TRUE, &cipher, &ivstring, PR_TRUE /* certs only */);
1b6f66
+    /* TODO: Fix discrepancy between our usage of the return value as
1b6f66
+     * as an int (a count) and the declaration as a SECStatus. */
1b6f66
+    nobjs = (int) ReadDERFromFile(&objs, certfile, PR_TRUE, &cipher, &ivstring, PR_TRUE /* certs only */);
1b6f66
     if (nobjs <= 0) {
1b6f66
         nss_ZFreeIf(objs);
1b6f66
         return CKR_GENERAL_ERROR;
1b6f66
@@ -515,8 +517,10 @@ AddCertificate(char *certfile, char *key
1b6f66
         if (keyfile) {          /* add the private key */
1b6f66
             SECItem **keyobjs = NULL;
1b6f66
             int kobjs = 0;
1b6f66
+            /* TODO: Fix discrepancy between our usage of the return value as
1b6f66
+             * as an int and the declaration as a SECStatus. */
1b6f66
             kobjs =
1b6f66
-                ReadDERFromFile(&keyobjs, keyfile, PR_TRUE, &cipher,
1b6f66
+                (int) ReadDERFromFile(&keyobjs, keyfile, PR_TRUE, &cipher,
1b6f66
                                 &ivstring, PR_FALSE);
1b6f66
             if (kobjs < 1) {
1b6f66
                 error = CKR_GENERAL_ERROR;
1b6f66
diff -up ./nss/lib/ckfw/pem/pobject.c.compile_Werror ./nss/lib/ckfw/pem/pobject.c
1b6f66
--- ./nss/lib/ckfw/pem/pobject.c.compile_Werror	2014-01-23 06:28:18.000000000 -0800
1b6f66
+++ ./nss/lib/ckfw/pem/pobject.c	2015-11-13 12:07:29.220887368 -0800
1b6f66
@@ -630,6 +630,11 @@ pem_DestroyInternalObject
1b6f66
         if (io->u.key.ivstring)
1b6f66
             free(io->u.key.ivstring);
1b6f66
         break;
1b6f66
+    case pemAll:
1b6f66
+        /* pemAll is not used, keep the compiler happy
1b6f66
+         * TODO: investigate a proper solution
1b6f66
+         */
1b6f66
+        return;
1b6f66
     }
1b6f66
 
1b6f66
     if (NULL != gobj)
1b6f66
@@ -1044,7 +1049,9 @@ pem_CreateObject
1b6f66
     int nobjs = 0;
1b6f66
     int i;
1b6f66
     int objid;
1b6f66
+#if 0
1b6f66
     pemToken *token;
1b6f66
+#endif
1b6f66
     int cipher;
1b6f66
     char *ivstring = NULL;
1b6f66
     pemInternalObject *listObj = NULL;
1b6f66
@@ -1073,7 +1080,9 @@ pem_CreateObject
1b6f66
     }
1b6f66
     slotID = nssCKFWSlot_GetSlotID(fwSlot);
1b6f66
 
1b6f66
+#if 0
1b6f66
     token = (pemToken *) mdToken->etc;
1b6f66
+#endif
1b6f66
 
1b6f66
     /*
1b6f66
      * only create keys and certs.
1b6f66
@@ -1114,7 +1123,11 @@ pem_CreateObject
1b6f66
     }
1b6f66
 
1b6f66
     if (objClass == CKO_CERTIFICATE) {
1b6f66
-        nobjs = ReadDERFromFile(&derlist, filename, PR_TRUE, &cipher, &ivstring, PR_TRUE /* certs only */);
1b6f66
+        /* TODO: Fix discrepancy between our usage of the return value as
1b6f66
+         * as an int and the declaration as a SECStatus. Typecasting as a
1b6f66
+         * temporary workaround.
1b6f66
+         */
1b6f66
+        nobjs = (int) ReadDERFromFile(&derlist, filename, PR_TRUE, &cipher, &ivstring, PR_TRUE /* certs only */);
1b6f66
         if (nobjs < 1)
1b6f66
             goto loser;
1b6f66
 
1b6f66
diff -up ./nss/lib/ckfw/pem/rsawrapr.c.compile_Werror ./nss/lib/ckfw/pem/rsawrapr.c
1b6f66
--- ./nss/lib/ckfw/pem/rsawrapr.c.compile_Werror	2014-01-23 06:28:18.000000000 -0800
1b6f66
+++ ./nss/lib/ckfw/pem/rsawrapr.c	2015-11-13 12:07:29.220887368 -0800
1b6f66
@@ -93,6 +93,8 @@ pem_PublicModulusLen(NSSLOWKEYPublicKey
1b6f66
     return 0;
1b6f66
 }
1b6f66
 
1b6f66
+/* unused functions */
1b6f66
+#if 0
1b6f66
 static SHA1Context *SHA1_CloneContext(SHA1Context * original)
1b6f66
 {
1b6f66
     SHA1Context *clone = NULL;
1b6f66
@@ -215,6 +217,7 @@ oaep_xor_with_h2(unsigned char *salt, un
1b6f66
 
1b6f66
     return SECSuccess;
1b6f66
 }
1b6f66
+#endif /* unused functions */
1b6f66
 
1b6f66
 /*
1b6f66
  * Format one block of data for public/private key encryption using
1b6f66
diff -up ./nss/lib/ckfw/pem/util.c.compile_Werror ./nss/lib/ckfw/pem/util.c
1b6f66
--- ./nss/lib/ckfw/pem/util.c.compile_Werror	2014-01-23 06:28:18.000000000 -0800
1b6f66
+++ ./nss/lib/ckfw/pem/util.c	2015-11-13 12:22:52.282196306 -0800
1b6f66
@@ -131,7 +131,8 @@ static SECStatus FileToItem(SECItem * ds
1b6f66
     return SECFailure;
1b6f66
 }
1b6f66
 
1b6f66
-int
1b6f66
+/* FIX: Returns a SECStatus yet callers take result as a count */
1b6f66
+SECStatus
1b6f66
 ReadDERFromFile(SECItem *** derlist, char *filename, PRBool ascii,
1b6f66
 		int *cipher, char **ivstring, PRBool certsonly)
1b6f66
 {
1b6f66
@@ -237,7 +238,12 @@ ReadDERFromFile(SECItem *** derlist, cha
1b6f66
 		    goto loser;
1b6f66
 		}
1b6f66
                 if ((certsonly && !key) || (!certsonly && key)) {
1b6f66
+		    error = CKR_OK;
1b6f66
 		    PUT_Object(der, error);
1b6f66
+		    if (error != CKR_OK) {
1b6f66
+			free(der);
1b6f66
+			goto loser;
1b6f66
+		    }
1b6f66
                 } else {
1b6f66
                     free(der->data);
1b6f66
                     free(der);
1b6f66
@@ -255,7 +261,12 @@ ReadDERFromFile(SECItem *** derlist, cha
1b6f66
 	    }
1b6f66
 
1b6f66
 	    /* NOTE: This code path has never been tested. */
1b6f66
+	    error = CKR_OK;
1b6f66
 	    PUT_Object(der, error);
1b6f66
+	    if (error != CKR_OK) {
1b6f66
+		free(der);
1b6f66
+		goto loser;
1b6f66
+	    }
1b6f66
 	}
1b6f66
 
1b6f66
 	nss_ZFreeIf(filedata.data);