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

« back to all changes in this revision

Viewing changes to mozilla/security/nss/lib/softoken/sdb.c

Tags: 3.12.8-0ubuntu0.10.10.1
* New upstream release v3.12.8 (NSS_3_12_8_RTM)
  - Fix browser wildcard certificate validation issue
  - Update root certs
  - Fix SSL deadlocks
* Refresh patches:
  - update debian/patches/38_kbsd.patch
  - update debian/patches/97_SSL_RENEGOTIATE_TRANSITIONAL.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
827
827
        goto loser;
828
828
    }
829
829
 
830
 
    getStr = sqlite3_mprintf("");
831
 
    for (i=0; getStr && i < count; i++) {
832
 
        if (i==0) {
833
 
            newStr = sqlite3_mprintf("a%x", template[i].type);
834
 
        } else {
835
 
            newStr = sqlite3_mprintf("%s, a%x", getStr, template[i].type);
 
830
    for (i=0; i < count; i++) {
 
831
        getStr = sqlite3_mprintf("a%x", template[i].type);
 
832
 
 
833
        if (getStr == NULL) {
 
834
            error = CKR_HOST_MEMORY;
 
835
            goto loser;
836
836
        }
 
837
 
 
838
        newStr = sqlite3_mprintf(GET_ATTRIBUTE_CMD, getStr, table);
837
839
        sqlite3_free(getStr);
838
 
        getStr = newStr;
839
 
    }
840
 
 
841
 
    if (getStr == NULL) {
842
 
        error = CKR_HOST_MEMORY;
843
 
        goto loser;
844
 
    }
845
 
 
846
 
    newStr = sqlite3_mprintf(GET_ATTRIBUTE_CMD, getStr, table);
847
 
    sqlite3_free(getStr);
848
 
    getStr = NULL;
849
 
    if (newStr == NULL) {
850
 
        error = CKR_HOST_MEMORY;
851
 
        goto loser;
852
 
    }
853
 
 
854
 
    sqlerr = sqlite3_prepare_v2(sqlDB, newStr, -1, &stmt, NULL);
855
 
    if (sqlerr != SQLITE_OK) { goto loser; }
856
 
    sqlerr = sqlite3_bind_int(stmt, 1, object_id);
857
 
    if (sqlerr != SQLITE_OK) { goto loser; }
858
 
    do {
859
 
        sqlerr = sqlite3_step(stmt);
860
 
        if (sqlerr == SQLITE_BUSY) {
861
 
            PR_Sleep(SDB_BUSY_RETRY_TIME);
 
840
        getStr = NULL;
 
841
        if (newStr == NULL) {
 
842
            error = CKR_HOST_MEMORY;
 
843
            goto loser;
862
844
        }
863
 
        if (sqlerr == SQLITE_ROW) {
864
 
            for (i=0; i < count; i++) {
865
 
                int column = i;
 
845
 
 
846
        sqlerr = sqlite3_prepare_v2(sqlDB, newStr, -1, &stmt, NULL);
 
847
        sqlite3_free(newStr);
 
848
        newStr = NULL;
 
849
        if (sqlerr == SQLITE_ERROR) {
 
850
            template[i].ulValueLen = -1;
 
851
            error = CKR_ATTRIBUTE_TYPE_INVALID;
 
852
            continue;
 
853
        } else if (sqlerr != SQLITE_OK) { goto loser; }
 
854
 
 
855
        sqlerr = sqlite3_bind_int(stmt, 1, object_id);
 
856
        if (sqlerr != SQLITE_OK) { goto loser; }
 
857
 
 
858
        do {
 
859
            sqlerr = sqlite3_step(stmt);
 
860
            if (sqlerr == SQLITE_BUSY) {
 
861
                PR_Sleep(SDB_BUSY_RETRY_TIME);
 
862
            }
 
863
            if (sqlerr == SQLITE_ROW) {
866
864
                int blobSize;
867
865
                const char *blobData;
868
866
 
869
 
                blobSize = sqlite3_column_bytes(stmt, column);
870
 
                blobData = sqlite3_column_blob(stmt, column);
 
867
                blobSize = sqlite3_column_bytes(stmt, 0);
 
868
                blobData = sqlite3_column_blob(stmt, 0);
871
869
                if (blobData == NULL) {
872
870
                    template[i].ulValueLen = -1;
873
871
                    error = CKR_ATTRIBUTE_TYPE_INVALID; 
874
 
                    continue;
 
872
                    break;
875
873
                }
876
874
                /* If the blob equals our explicit NULL value, then the 
877
875
                 * attribute is a NULL. */
884
882
                    if (template[i].ulValueLen < blobSize) {
885
883
                        template[i].ulValueLen = -1;
886
884
                        error = CKR_BUFFER_TOO_SMALL;
887
 
                        continue;
 
885
                        break;
888
886
                    }
889
887
                    PORT_Memcpy(template[i].pValue, blobData, blobSize);
890
888
                }
891
889
                template[i].ulValueLen = blobSize;
 
890
                found = 1;
892
891
            }
893
 
            found = 1;
894
 
        }
895
 
    } while (!sdb_done(sqlerr,&retry));
 
892
        } while (!sdb_done(sqlerr,&retry));
 
893
        sqlite3_reset(stmt);
 
894
        sqlite3_finalize(stmt);
 
895
        stmt = NULL;
 
896
    }
896
897
 
897
898
loser:
898
899
    /* fix up the error if necessary */
902
903
            error = CKR_OBJECT_HANDLE_INVALID;
903
904
        }
904
905
    }
905
 
    if (newStr) {
906
 
        sqlite3_free(newStr);
907
 
    }
908
906
 
909
907
    if (stmt) {
910
908
        sqlite3_reset(stmt);