~ubuntu-branches/ubuntu/karmic/nss/karmic-updates

« back to all changes in this revision

Viewing changes to mozilla/security/nss/lib/ckfw/instance.c

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2009-06-16 13:23:47 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090616132347-311ysb8oep74b98y
Tags: 3.12.3-0ubuntu1
* new upstream release 3.12.3 RTM (NSS_3_12_3_RTM) (LP: #387751)
* adjust patches to changed upstream code base
  - update debian/patches/38_kbsd.patch
* needs nspr >= 4.7.4
  - update debian/control
* update 85_security_load.patch to latest debian version
  - update debian/patches/85_security_load.patch
* add new symbols for 3.12.3
  - 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: instance.c,v $ $Revision: 1.11 $ $Date: 2006/10/09 22:16:59 $";
 
38
static const char CVS_ID[] = "@(#) $RCSfile: instance.c,v $ $Revision: 1.12 $ $Date: 2009/02/09 07:55:52 $";
39
39
#endif /* DEBUG */
40
40
 
41
41
/*
208
208
    return (NSSCKFWInstance *)NULL;
209
209
  }
210
210
 
211
 
  if( (NSSCKMDInstance *)NULL == mdInstance ) {
 
211
  if (!mdInstance) {
212
212
    *pError = CKR_ARGUMENTS_BAD;
213
213
    return (NSSCKFWInstance *)NULL;
214
214
  }
215
215
#endif /* NSSDEBUG */
216
216
 
217
217
  arena = NSSArena_Create();
218
 
  if( (NSSArena *)NULL == arena ) {
 
218
  if (!arena) {
219
219
    *pError = CKR_HOST_MEMORY;
220
220
    return (NSSCKFWInstance *)NULL;
221
221
  }
222
222
 
223
223
  fwInstance = nss_ZNEW(arena, NSSCKFWInstance);
224
 
  if( (NSSCKFWInstance *)NULL == fwInstance ) {
 
224
  if (!fwInstance) {
225
225
    goto nomem;
226
226
  }
227
227
 
244
244
 
245
245
  fwInstance->mutex = nssCKFWMutex_Create(pInitArgs, LockingState, arena,
246
246
                                          pError);
247
 
  if( (NSSCKFWMutex *)NULL == fwInstance->mutex ) {
 
247
  if (!fwInstance->mutex) {
248
248
    if( CKR_OK == *pError ) {
249
249
      *pError = CKR_GENERAL_ERROR;
250
250
    }
251
251
    goto loser;
252
252
  }
253
253
 
254
 
  if( (void *)NULL != (void *)mdInstance->Initialize ) {
 
254
  if (mdInstance->Initialize) {
255
255
    *pError = mdInstance->Initialize(mdInstance, fwInstance, fwInstance->configurationData);
256
256
    if( CKR_OK != *pError ) {
257
257
      goto loser;
260
260
    called_Initialize = CK_TRUE;
261
261
  }
262
262
 
263
 
  if( (void *)NULL != (void *)mdInstance->ModuleHandlesSessionObjects ) {
 
263
  if (mdInstance->ModuleHandlesSessionObjects) {
264
264
    fwInstance->moduleHandlesSessionObjects = 
265
265
      mdInstance->ModuleHandlesSessionObjects(mdInstance, fwInstance);
266
266
  } else {
267
267
    fwInstance->moduleHandlesSessionObjects = CK_FALSE;
268
268
  }
269
269
 
270
 
  if( (void *)NULL == (void *)mdInstance->GetNSlots ) {
 
270
  if (!mdInstance->GetNSlots) {
271
271
    /* That routine is required */
272
272
    *pError = CKR_GENERAL_ERROR;
273
273
    goto loser;
294
294
 
295
295
  fwInstance->sessionHandleHash = nssCKFWHash_Create(fwInstance, 
296
296
    fwInstance->arena, pError);
297
 
  if( (nssCKFWHash *)NULL == fwInstance->sessionHandleHash ) {
 
297
  if (!fwInstance->sessionHandleHash) {
298
298
    goto loser;
299
299
  }
300
300
 
301
301
  fwInstance->objectHandleHash = nssCKFWHash_Create(fwInstance,
302
302
    fwInstance->arena, pError);
303
 
  if( (nssCKFWHash *)NULL == fwInstance->objectHandleHash ) {
 
303
  if (!fwInstance->objectHandleHash) {
304
304
    goto loser;
305
305
  }
306
306
 
307
 
  if( (void *)NULL == (void *)mdInstance->GetSlots ) {
 
307
  if (!mdInstance->GetSlots) {
308
308
    /* That routine is required */
309
309
    *pError = CKR_GENERAL_ERROR;
310
310
    goto loser;
318
318
  for( i = 0; i < fwInstance->nSlots; i++ ) {
319
319
    NSSCKMDSlot *mdSlot = fwInstance->mdSlotList[i];
320
320
 
321
 
    if( (NSSCKMDSlot *)NULL == mdSlot ) {
 
321
    if (!mdSlot) {
322
322
      *pError = CKR_GENERAL_ERROR;
323
323
      goto loser;
324
324
    }
333
333
 
334
334
      for( j = i; j < fwInstance->nSlots; j++ ) {
335
335
        NSSCKMDSlot *mds = fwInstance->mdSlotList[j];
336
 
        if( (void *)NULL != (void *)mds->Destroy ) {
 
336
        if (mds->Destroy) {
337
337
          mds->Destroy(mds, (NSSCKFWSlot *)NULL, mdInstance, fwInstance);
338
338
        }
339
339
      }
362
362
 loser:
363
363
 
364
364
  if( CK_TRUE == called_Initialize ) {
365
 
    if( (void *)NULL != (void *)mdInstance->Finalize ) {
 
365
    if (mdInstance->Finalize) {
366
366
      mdInstance->Finalize(mdInstance, fwInstance);
367
367
    }
368
368
  }
401
401
    (void)nssCKFWSlot_Destroy(fwInstance->fwSlotList[i]);
402
402
  }
403
403
 
404
 
  if( (void *)NULL != (void *)fwInstance->mdInstance->Finalize ) {
 
404
  if (fwInstance->mdInstance->Finalize) {
405
405
    fwInstance->mdInstance->Finalize(fwInstance->mdInstance, fwInstance);
406
406
  }
407
407
 
452
452
)
453
453
{
454
454
#ifdef NSSDEBUG
455
 
  if( (CK_RV *)NULL == pError ) {
 
455
  if (!pError) {
456
456
    return (NSSArena *)NULL;
457
457
  }
458
458
 
500
500
  NSSCKFWMutex *mutex;
501
501
 
502
502
#ifdef NSSDEBUG
503
 
  if( (CK_RV *)NULL == pError ) {
 
503
  if (!pError) {
504
504
    return (NSSCKFWMutex *)NULL;
505
505
  }
506
506
 
512
512
 
513
513
  mutex = nssCKFWMutex_Create(fwInstance->pInitArgs, fwInstance->LockingState,
514
514
                              arena, pError);
515
 
  if( (NSSCKFWMutex *)NULL == mutex ) {
 
515
  if (!mutex) {
516
516
    if( CKR_OK == *pError ) {
517
517
      *pError = CKR_GENERAL_ERROR;
518
518
    }
576
576
  CK_SESSION_HANDLE hSession;
577
577
 
578
578
#ifdef NSSDEBUG
579
 
  if( (CK_RV *)NULL == pError ) {
 
579
  if (!pError) {
580
580
    return (CK_SESSION_HANDLE)0;
581
581
  }
582
582
 
720
720
  CK_OBJECT_HANDLE hObject;
721
721
 
722
722
#ifdef NSSDEBUG
723
 
  if( (CK_RV *)NULL == pError ) {
 
723
  if (!pError) {
724
724
    return (CK_OBJECT_HANDLE)0;
725
725
  }
726
726
 
905
905
)
906
906
{
907
907
#ifdef NSSDEBUG
908
 
  if( (CK_RV *)NULL == pError ) {
 
908
  if (!pError) {
909
909
    return (CK_ULONG)0;
910
910
  }
911
911
 
949
949
    goto done;
950
950
  }
951
951
 
952
 
  if( (void *)NULL != (void *)fwInstance->mdInstance->GetCryptokiVersion ) {
 
952
  if (fwInstance->mdInstance->GetCryptokiVersion) {
953
953
    fwInstance->cryptokiVersion = fwInstance->mdInstance->GetCryptokiVersion(
954
954
      fwInstance->mdInstance, fwInstance);
955
955
  } else {
993
993
    return error;
994
994
  }
995
995
 
996
 
  if( (NSSUTF8 *)NULL == fwInstance->manufacturerID ) {
997
 
    if( (void *)NULL != (void *)fwInstance->mdInstance->GetManufacturerID ) {
 
996
  if (!fwInstance->manufacturerID) {
 
997
    if (fwInstance->mdInstance->GetManufacturerID) {
998
998
      fwInstance->manufacturerID = fwInstance->mdInstance->GetManufacturerID(
999
999
        fwInstance->mdInstance, fwInstance, &error);
1000
 
      if( ((NSSUTF8 *)NULL == fwInstance->manufacturerID) && (CKR_OK != error) ) {
 
1000
      if ((!fwInstance->manufacturerID) && (CKR_OK != error)) {
1001
1001
        goto done;
1002
1002
      }
1003
1003
    } else {
1062
1062
    return error;
1063
1063
  }
1064
1064
 
1065
 
  if( (NSSUTF8 *)NULL == fwInstance->libraryDescription ) {
1066
 
    if( (void *)NULL != (void *)fwInstance->mdInstance->GetLibraryDescription ) {
 
1065
  if (!fwInstance->libraryDescription) {
 
1066
    if (fwInstance->mdInstance->GetLibraryDescription) {
1067
1067
      fwInstance->libraryDescription = fwInstance->mdInstance->GetLibraryDescription(
1068
1068
        fwInstance->mdInstance, fwInstance, &error);
1069
 
      if( ((NSSUTF8 *)NULL == fwInstance->libraryDescription) && (CKR_OK != error) ) {
 
1069
      if ((!fwInstance->libraryDescription) && (CKR_OK != error)) {
1070
1070
        goto done;
1071
1071
      }
1072
1072
    } else {
1112
1112
    goto done;
1113
1113
  }
1114
1114
 
1115
 
  if( (void *)NULL != (void *)fwInstance->mdInstance->GetLibraryVersion ) {
 
1115
  if (fwInstance->mdInstance->GetLibraryVersion) {
1116
1116
    fwInstance->libraryVersion = fwInstance->mdInstance->GetLibraryVersion(
1117
1117
      fwInstance->mdInstance, fwInstance);
1118
1118
  } else {
1157
1157
)
1158
1158
{
1159
1159
#ifdef NSSDEBUG
1160
 
  if( (CK_RV *)NULL == pError ) {
 
1160
  if (!pError) {
1161
1161
    return (NSSCKFWSlot **)NULL;
1162
1162
  }
1163
1163
 
1187
1187
  CK_ULONG i, n;
1188
1188
 
1189
1189
#ifdef NSSDEBUG
1190
 
  if( (CK_RV *)NULL == pError ) {
 
1190
  if (!pError) {
1191
1191
    return (NSSCKFWSlot *)NULL;
1192
1192
  }
1193
1193
 
1206
1206
  }
1207
1207
#endif /* NSSDEBUG */
1208
1208
 
1209
 
  if( (void *)NULL == (void *)fwInstance->mdInstance->WaitForSlotEvent ) {
 
1209
  if (!fwInstance->mdInstance->WaitForSlotEvent) {
1210
1210
    *pError = CKR_NO_EVENT;
1211
1211
    return (NSSCKFWSlot *)NULL;
1212
1212
  }
1218
1218
    pError
1219
1219
  );
1220
1220
 
1221
 
  if( (NSSCKMDSlot *)NULL == mdSlot ) {
 
1221
  if (!mdSlot) {
1222
1222
    return (NSSCKFWSlot *)NULL;
1223
1223
  }
1224
1224
 
1234
1234
    }
1235
1235
  }
1236
1236
 
1237
 
  if( (NSSCKFWSlot *)NULL == fwSlot ) {
 
1237
  if (!fwSlot) {
1238
1238
    /* Internal error */
1239
1239
    *pError = CKR_GENERAL_ERROR;
1240
1240
    return (NSSCKFWSlot *)NULL;
1274
1274
)
1275
1275
{
1276
1276
#ifdef DEBUG
1277
 
  if( (CK_RV *)NULL == pError ) {
 
1277
  if (!pError) {
1278
1278
    return (NSSArena *)NULL;
1279
1279
  }
1280
1280
 
1319
1319
)
1320
1320
{
1321
1321
#ifdef DEBUG
1322
 
  if( (CK_RV *)NULL == pError ) {
 
1322
  if (!pError) {
1323
1323
    return (NSSCKFWMutex *)NULL;
1324
1324
  }
1325
1325