]> git.ipfire.org Git - people/amarx/ipfire-3.x.git/blob - nss/patches/nsspem-init-inform-not-thread-safe.patch0
libsolv: Update to git version f663ca2.
[people/amarx/ipfire-3.x.git] / nss / patches / nsspem-init-inform-not-thread-safe.patch0
1 --- mozilla/security/nss/lib/ckfw/pem/pinst.c.736410 2010-11-25 11:51:52.000000000 -0800
2 +++ mozilla/security/nss/lib/ckfw/pem/pinst.c 2011-09-13 16:59:49.325215540 -0700
3 @@ -364,39 +364,37 @@ AddObjectIfNeeded(CK_OBJECT_CLASS objCla
4 size += PEM_ITEM_CHUNK;
5 }
6 gobj[count] = io;
7 count++;
8 pem_nobjs++;
9
10 io->refCount ++;
11 return io;
12 }
13
14 CK_RV
15 AddCertificate(char *certfile, char *keyfile, PRBool cacert,
16 CK_SLOT_ID slotID)
17 {
18 pemInternalObject *o;
19 - SECItem certDER;
20 CK_RV error = 0;
21 int objid, i;
22 int nobjs = 0;
23 SECItem **objs = NULL;
24 char *ivstring = NULL;
25 int cipher;
26
27 - certDER.data = NULL;
28 nobjs = ReadDERFromFile(&objs, certfile, PR_TRUE, &cipher, &ivstring, PR_TRUE /* certs only */);
29 if (nobjs <= 0) {
30 nss_ZFreeIf(objs);
31 return CKR_GENERAL_ERROR;
32 }
33
34 /* For now load as many certs as are in the file for CAs only */
35 if (cacert) {
36 for (i = 0; i < nobjs; i++) {
37 char nickname[1024];
38 objid = pem_nobjs + 1;
39
40 snprintf(nickname, 1024, "%s - %d", certfile, i);
41
42 o = AddObjectIfNeeded(CKO_CERTIFICATE, pemCert, objs[i], NULL,
43 @@ -456,72 +454,76 @@ AddCertificate(char *certfile, char *key
44 loser:
45 nss_ZFreeIf(objs);
46 nss_ZFreeIf(o);
47 return error;
48 }
49
50 CK_RV
51 pem_Initialize
52 (
53 NSSCKMDInstance * mdInstance,
54 NSSCKFWInstance * fwInstance,
55 NSSUTF8 * configurationData
56 )
57 {
58 CK_RV rv;
59 - /* parse the initialization string and initialize CRLInstances */
60 + /* parse the initialization string */
61 char **certstrings = NULL;
62 + char *modparms = NULL;
63 PRInt32 numcerts = 0;
64 PRBool status, error = PR_FALSE;
65 int i;
66 + CK_C_INITIALIZE_ARGS_PTR modArgs = NULL;
67 +
68 + if (!fwInstance) return CKR_ARGUMENTS_BAD;
69 +
70 + modArgs = NSSCKFWInstance_GetInitArgs(fwInstance);
71 + if (modArgs &&
72 + ((modArgs->flags & CKF_OS_LOCKING_OK) || (modArgs->CreateMutex != 0))) {
73 + return CKR_CANT_LOCK;
74 + }
75
76 if (pemInitialized) {
77 return CKR_OK;
78 }
79 +
80 RNG_RNGInit();
81
82 open_log();
83
84 plog("pem_Initialize\n");
85
86 - unsigned char *modparms = NULL;
87 - if (!fwInstance) {
88 - return CKR_ARGUMENTS_BAD;
89 - }
90 -
91 - CK_C_INITIALIZE_ARGS_PTR modArgs =
92 - NSSCKFWInstance_GetInitArgs(fwInstance);
93 if (!modArgs || !modArgs->LibraryParameters) {
94 goto done;
95 }
96 - modparms = (unsigned char *) modArgs->LibraryParameters;
97 + modparms = (char *) modArgs->LibraryParameters;
98 plog("Initialized with %s\n", modparms);
99
100 /*
101 * The initialization string format is a space-delimited file of
102 * pairs of paths which are delimited by a semi-colon. The first
103 * entry of the pair is the path to the certificate file. The
104 * second is the path to the key file.
105 *
106 * CA certificates do not need the semi-colon.
107 *
108 * Example:
109 * /etc/certs/server.pem;/etc/certs/server.key /etc/certs/ca.pem
110 *
111 */
112 status =
113 - pem_ParseString((const char *) modparms, ' ', &numcerts,
114 + pem_ParseString(modparms, ' ', &numcerts,
115 &certstrings);
116 if (status == PR_FALSE) {
117 return CKR_ARGUMENTS_BAD;
118 }
119
120 for (i = 0; i < numcerts && error != PR_TRUE; i++) {
121 char *cert = certstrings[i];
122 PRInt32 attrcount = 0;
123 char **certattrs = NULL;
124 status = pem_ParseString(cert, ';', &attrcount, &certattrs);
125 if (status == PR_FALSE) {
126 error = PR_TRUE;
127 break;
128 }
129