~ubuntu-branches/ubuntu/raring/nss/raring-security

« back to all changes in this revision

Viewing changes to mozilla/security/nss/lib/pki/pkibase.c

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2010-03-25 13:46:06 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20100325134606-bl6liuok2w9l7snv
Tags: 3.12.6-0ubuntu1
* New upstream release 3.12.6 RTM (NSS_3_12_6_RTM)
  - fixes CVE-2009-3555 aka US-CERT VU#120541
* Adjust patches to changed upstream code base
  - update debian/patches/38_kbsd.patch
  - update debian/patches/38_mips64_build.patch
  - update debian/patches/85_security_load.patch
* Remove patches that are merged upstream
  - delete debian/patches/91_nonexec_stack.patch
  - update debian/patches/series
* Bump nspr dependency to 4.8
  - update debian/control
* Add new symbols for 3.12.6
  - update debian/libnss3-1d.symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 * ***** END LICENSE BLOCK ***** */
36
36
 
37
37
#ifdef DEBUG
38
 
static const char CVS_ID[] = "@(#) $RCSfile: pkibase.c,v $ $Revision: 1.30 $ $Date: 2008/01/21 23:20:19 $";
 
38
static const char CVS_ID[] = "@(#) $RCSfile: pkibase.c,v $ $Revision: 1.31 $ $Date: 2009/04/17 19:28:07 $";
39
39
#endif /* DEBUG */
40
40
 
41
41
#ifndef DEV_H
199
199
  nssCryptokiObject *instance
200
200
)
201
201
{
 
202
    nssCryptokiObject **newInstances = NULL;
 
203
 
202
204
    nssPKIObject_Lock(object);
203
205
    if (object->numInstances == 0) {
204
 
        object->instances = nss_ZNEWARRAY(object->arena,
205
 
                                          nssCryptokiObject *,
206
 
                                          object->numInstances + 1);
 
206
        newInstances = nss_ZNEWARRAY(object->arena,
 
207
                                     nssCryptokiObject *,
 
208
                                     object->numInstances + 1);
207
209
    } else {
 
210
        PRBool found = PR_FALSE;
208
211
        PRUint32 i;
209
212
        for (i=0; i<object->numInstances; i++) {
210
213
            if (nssCryptokiObject_Equal(object->instances[i], instance)) {
211
 
                nssPKIObject_Unlock(object);
212
 
                if (instance->label) {
213
 
                    if (!object->instances[i]->label ||
214
 
                        !nssUTF8_Equal(instance->label,
215
 
                                       object->instances[i]->label, NULL))
216
 
                    {
217
 
                        /* Either the old instance did not have a label,
218
 
                         * or the label has changed.
219
 
                         */
220
 
                        nss_ZFreeIf(object->instances[i]->label);
221
 
                        object->instances[i]->label = instance->label;
222
 
                        instance->label = NULL;
223
 
                    }
224
 
                } else if (object->instances[i]->label) {
225
 
                    /* The old label was removed */
226
 
                    nss_ZFreeIf(object->instances[i]->label);
227
 
                    object->instances[i]->label = NULL;
228
 
                }
229
 
                nssCryptokiObject_Destroy(instance);
230
 
                return PR_SUCCESS;
 
214
                found = PR_TRUE;
 
215
                break;
231
216
            }
232
217
        }
233
 
        object->instances = nss_ZREALLOCARRAY(object->instances,
234
 
                                              nssCryptokiObject *,
235
 
                                              object->numInstances + 1);
236
 
    }
237
 
    if (!object->instances) {
238
 
        nssPKIObject_Unlock(object);
239
 
        return PR_FAILURE;
240
 
    }
241
 
    object->instances[object->numInstances++] = instance;
 
218
        if (found) {
 
219
            /* The new instance is identical to one in the array, except
 
220
             * perhaps that the label may be different.  So replace 
 
221
             * the label in the array instance with the label from the 
 
222
             * new instance, and discard the new instance.
 
223
             */
 
224
            nss_ZFreeIf(object->instances[i]->label);
 
225
            object->instances[i]->label = instance->label;
 
226
            nssPKIObject_Unlock(object);
 
227
            instance->label = NULL;
 
228
            nssCryptokiObject_Destroy(instance);
 
229
            return PR_SUCCESS;
 
230
        }
 
231
        newInstances = nss_ZREALLOCARRAY(object->instances,
 
232
                                         nssCryptokiObject *,
 
233
                                         object->numInstances + 1);
 
234
    }
 
235
    if (newInstances) {
 
236
        object->instances = newInstances;
 
237
        newInstances[object->numInstances++] = instance;
 
238
    }
242
239
    nssPKIObject_Unlock(object);
243
 
    return PR_SUCCESS;
 
240
    return (newInstances ? PR_SUCCESS : PR_FAILURE);
244
241
}
245
242
 
246
243
NSS_IMPLEMENT PRBool