Changeset 113


Ignore:
Timestamp:
12/06/08 19:43:46 (3 years ago)
Author:
martin
Message:

avoid errors like #12 in the future

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/engine_pkcs11.c

    r112 r113  
    549549        PKCS11_CERT *certs; 
    550550        EVP_PKEY *pk; 
    551         unsigned int count, n, m; 
     551        unsigned int slot_count, cert_count, key_count, n, m; 
    552552        unsigned char key_id[MAX_VALUE_LEN / 2]; 
    553553        size_t key_id_len = sizeof(key_id); 
     
    583583        } 
    584584 
    585         if (PKCS11_enumerate_slots(ctx, &slot_list, &count) < 0) 
     585        if (PKCS11_enumerate_slots(ctx, &slot_list, &slot_count) < 0) 
    586586                fail("failed to enumerate slots\n"); 
    587587 
    588588        if (verbose) { 
    589                 fprintf(stderr, "Found %u slot%s\n", count, 
    590                         (count <= 1) ? "" : "s"); 
    591         } 
    592         for (n = 0; n < count; n++) { 
     589                fprintf(stderr, "Found %u slot%s\n", slot_count, 
     590                        (slot_count <= 1) ? "" : "s"); 
     591        } 
     592        for (n = 0; n < slot_count; n++) { 
    593593                slot = slot_list + n; 
    594594                flags[0] = '\0'; 
     
    622622 
    623623        if (slot_nr == -1) { 
    624                 if (!(slot = PKCS11_find_token(ctx, slot_list, count))) 
     624                if (!(slot = PKCS11_find_token(ctx, slot_list, slot_count))) 
    625625                        fail("didn't find any tokens\n"); 
    626         } else if (slot_nr >= 0 && slot_nr < count) 
     626        } else if (slot_nr >= 0 && slot_nr < slot_count) 
    627627                slot = slot_list + slot_nr; 
    628628        else { 
    629629                fprintf(stderr, "Invalid slot number: %d\n", slot_nr); 
    630                 PKCS11_release_all_slots(ctx, slot_list, count); 
     630                PKCS11_release_all_slots(ctx, slot_list, slot_count); 
    631631                return NULL; 
    632632        } 
     
    635635        if (tok == NULL) { 
    636636                fprintf(stderr, "Found empty token; \n"); 
    637                 PKCS11_release_all_slots(ctx, slot_list, count); 
     637                PKCS11_release_all_slots(ctx, slot_list, slot_count); 
    638638                return NULL; 
    639639        } 
     
    647647        if (isPrivate && !tok->userPinSet && !tok->readOnly) { 
    648648                fprintf(stderr, "Found slot without user PIN\n"); 
    649                 PKCS11_release_all_slots(ctx, slot_list, count); 
     649                PKCS11_release_all_slots(ctx, slot_list, slot_count); 
    650650                return NULL; 
    651651        } 
     
    656656        } 
    657657 
    658         if (PKCS11_enumerate_certs(tok, &certs, &count)) 
     658        if (PKCS11_enumerate_certs(tok, &certs, &cert_count)) 
    659659                fail("unable to enumerate certificates\n"); 
    660660 
    661661        if (verbose) { 
    662                 fprintf(stderr, "Found %u certificate%s:\n", count, 
    663                         (count <= 1) ? "" : "s"); 
    664                 for (n = 0; n < count; n++) { 
     662                fprintf(stderr, "Found %u certificate%s:\n", cert_count, 
     663                        (cert_count <= 1) ? "" : "s"); 
     664                for (n = 0; n < cert_count; n++) { 
    665665                        PKCS11_CERT *c = certs + n; 
    666666                        char *dn = NULL; 
     
    732732 
    733733        /* Make sure there is at least one private key on the token */ 
    734         if (PKCS11_enumerate_keys(tok, &keys, &count)) { 
     734        if (PKCS11_enumerate_keys(tok, &keys, &key_count)) { 
    735735                fail("unable to enumerate keys\n"); 
    736736        } 
    737         if (count == 0) { 
     737        if (key_count == 0) { 
    738738                fail("No keys found.\n"); 
    739739        } 
    740740 
    741741        if (verbose) { 
    742                 fprintf(stderr, "Found %u key%s:\n", count, 
    743                         (count <= 1) ? "" : "s"); 
     742                fprintf(stderr, "Found %u key%s:\n", key_count, 
     743                        (key_count <= 1) ? "" : "s"); 
    744744        } 
    745745        if (s_slot_key_id && *s_slot_key_id) { 
    746                 for (n = 0; n < count; n++) { 
     746                for (n = 0; n < key_count; n++) { 
    747747                        PKCS11_KEY *k = keys + n; 
    748748 
Note: See TracChangeset for help on using the changeset viewer.