project
stringclasses
633 values
commit_id
stringlengths
7
81
target
int64
0
1
func
stringlengths
5
484k
cwe
stringclasses
131 values
big_vul_idx
float64
0
189k
idx
int64
0
522k
hash
stringlengths
34
39
size
float64
1
24k
message
stringlengths
0
11.5k
dataset
stringclasses
1 value
sqlcipher
cb71f53e8cea4802509f182fa5bead0ac6ab0e7f
0
int sqlite3_rekey(sqlite3 *db, const void *pKey, int nKey) { CODEC_TRACE("sqlite3_rekey entered: db=%p pKey=%s nKey=%d\n", db, (char *)pKey, nKey); return sqlite3_rekey_v2(db, "main", pKey, nKey); }
CWE-476
null
521,513
124990925950342494676970472549811023531
null
null
other
sqlcipher
cb71f53e8cea4802509f182fa5bead0ac6ab0e7f
0
int sqlite3_key_v2(sqlite3 *db, const char *zDb, const void *pKey, int nKey) { CODEC_TRACE("sqlite3_key_v2: entered db=%p zDb=%s pKey=%s nKey=%d\n", db, zDb, (char *)pKey, nKey); /* attach key if db and pKey are not null and nKey is > 0 */ if(db && pKey && nKey) { int db_index = sqlcipher_find_db_index(db, zDb); return sqlite3CodecAttach(db, db_index, pKey, nKey); } return SQLITE_ERROR; }
CWE-476
null
521,514
73166029779090012427420417688273038704
null
null
other
sqlcipher
cb71f53e8cea4802509f182fa5bead0ac6ab0e7f
0
int sqlcipher_find_db_index(sqlite3 *db, const char *zDb) { int db_index; if(zDb == NULL){ return 0; } for(db_index = 0; db_index < db->nDb; db_index++) { struct Db *pDb = &db->aDb[db_index]; if(strcmp(pDb->zDbSName, zDb) == 0) { return db_index; } } return 0; }
CWE-476
null
521,515
289985726554989780948533248680267463560
null
null
other
sqlcipher
cb71f53e8cea4802509f182fa5bead0ac6ab0e7f
0
void sqlite3CodecGetKey(sqlite3* db, int nDb, void **zKey, int *nKey) { struct Db *pDb = &db->aDb[nDb]; CODEC_TRACE("sqlite3CodecGetKey: entered db=%p, nDb=%d\n", db, nDb); if( pDb->pBt ) { codec_ctx *ctx = (codec_ctx*) sqlite3PagerGetCodec(pDb->pBt->pBt->pPager); if(ctx) { /* pass back the keyspec from the codec, unless PRAGMA cipher_store_pass is set or keyspec has not yet been derived, in which case pass back the password key material */ sqlcipher_codec_get_keyspec(ctx, zKey, nKey); if(sqlcipher_codec_get_store_pass(ctx) == 1 || *zKey == NULL) { sqlcipher_codec_get_pass(ctx, zKey, nKey); } } else { *zKey = NULL; *nKey = 0; } } }
CWE-476
null
521,516
171276717307175347937129546147676145159
null
null
other
node-lmdb
97760104c0fd311206b88aecd91fa1f59fe2b85a
0
NAN_METHOD(TxnWrap::reset) { Nan::HandleScope scope; TxnWrap *tw = Nan::ObjectWrap::Unwrap<TxnWrap>(info.This()); if (!tw->txn) { return Nan::ThrowError("The transaction is already closed."); } mdb_txn_reset(tw->txn); }
NVD-CWE-noinfo
null
522,366
111754536856151020384296457165593354112
null
null
other
node-lmdb
97760104c0fd311206b88aecd91fa1f59fe2b85a
0
NAN_METHOD(TxnWrap::getStringUnsafe) { return getCommon(info, valToStringUnsafe); }
NVD-CWE-noinfo
null
522,367
327997749649427003529712935162733995691
null
null
other
node-lmdb
97760104c0fd311206b88aecd91fa1f59fe2b85a
0
TxnWrap::~TxnWrap() { // Close if not closed already if (this->txn) { mdb_txn_abort(txn); this->removeFromEnvWrap(); } }
NVD-CWE-noinfo
null
522,368
98633485475874360673390197125564066465
null
null
other
node-lmdb
97760104c0fd311206b88aecd91fa1f59fe2b85a
0
NAN_METHOD(TxnWrap::renew) { Nan::HandleScope scope; TxnWrap *tw = Nan::ObjectWrap::Unwrap<TxnWrap>(info.This()); if (!tw->txn) { return Nan::ThrowError("The transaction is already closed."); } int rc = mdb_txn_renew(tw->txn); if (rc != 0) { return throwLmdbError(rc); } }
NVD-CWE-noinfo
null
522,369
330310888177677195012960504845799002590
null
null
other
node-lmdb
97760104c0fd311206b88aecd91fa1f59fe2b85a
0
NAN_METHOD(TxnWrap::getBinaryUnsafe) { return getCommon(info, valToBinaryUnsafe); }
NVD-CWE-noinfo
null
522,370
154435709708493451549133124651591851111
null
null
other
node-lmdb
97760104c0fd311206b88aecd91fa1f59fe2b85a
0
TxnWrap::TxnWrap(MDB_env *env, MDB_txn *txn) { this->env = env; this->txn = txn; this->flags = 0; }
NVD-CWE-noinfo
null
522,371
20378928412779517955065624189665146904
null
null
other
node-lmdb
97760104c0fd311206b88aecd91fa1f59fe2b85a
0
NAN_METHOD(TxnWrap::putString) { if (!info[2]->IsString()) return Nan::ThrowError("Value must be a string."); return putCommon(info, [](Nan::NAN_METHOD_ARGS_TYPE info, MDB_val &data) -> void { CustomExternalStringResource::writeTo(Local<String>::Cast(info[2]), &data); }, [](MDB_val &data) -> void { delete[] (uint16_t*)data.mv_data; }); }
NVD-CWE-noinfo
null
522,372
90464922304161758037637442655888907352
null
null
other
node-lmdb
97760104c0fd311206b88aecd91fa1f59fe2b85a
0
NAN_METHOD(TxnWrap::putNumber) { return putCommon(info, [](Nan::NAN_METHOD_ARGS_TYPE info, MDB_val &data) -> void { auto numberLocal = Nan::To<v8::Number>(info[2]).ToLocalChecked(); numberToPut = numberLocal->Value(); data.mv_size = sizeof(double); data.mv_data = &numberToPut; }, nullptr); }
NVD-CWE-noinfo
null
522,373
84506492187481645784841167051352604929
null
null
other
node-lmdb
97760104c0fd311206b88aecd91fa1f59fe2b85a
0
NAN_METHOD(TxnWrap::del) { Nan::HandleScope scope; // Check argument count auto argCount = info.Length(); if (argCount < 2 || argCount > 4) { return Nan::ThrowError("Invalid number of arguments to cursor.del, should be: (a) <dbi>, <key> (b) <dbi>, <key>, <options> (c) <dbi>, <key>, <data> (d) <dbi>, <key>, <data>, <options>"); } // Unwrap native objects TxnWrap *tw = Nan::ObjectWrap::Unwrap<TxnWrap>(info.This()); DbiWrap *dw = Nan::ObjectWrap::Unwrap<DbiWrap>(Local<Object>::Cast(info[0])); if (!tw->txn) { return Nan::ThrowError("The transaction is already closed."); } // Take care of options object and data handle Local<Value> options; Local<Value> dataHandle; if (argCount == 4) { options = info[3]; dataHandle = info[2]; } else if (argCount == 3) { if (info[2]->IsObject()) { options = info[2]; dataHandle = Nan::Undefined(); } else { options = Nan::Undefined(); dataHandle = info[2]; } } else if (argCount == 2) { options = Nan::Undefined(); dataHandle = Nan::Undefined(); } else { return Nan::ThrowError("Unknown arguments to cursor.del, this could be a node-lmdb bug!"); } MDB_val key; bool keyIsValid; auto keyType = inferAndValidateKeyType(info[1], options, dw->keyType, keyIsValid); if (!keyIsValid) { // inferAndValidateKeyType already threw an error return; } auto freeKey = argToKey(info[1], key, keyType, keyIsValid); if (!keyIsValid) { // argToKey already threw an error return; } // Set data if dupSort true and data given MDB_val data; bool freeData = false; if ((dw->flags & MDB_DUPSORT) && !(dataHandle->IsUndefined())) { if (dataHandle->IsString()) { CustomExternalStringResource::writeTo(Local<String>::Cast(dataHandle), &data); freeData = true; } else if (node::Buffer::HasInstance(dataHandle)) { data.mv_size = node::Buffer::Length(dataHandle); data.mv_data = node::Buffer::Data(dataHandle); freeData = true; } else if (dataHandle->IsNumber()) { auto numberLocal = Nan::To<v8::Number>(dataHandle).ToLocalChecked(); data.mv_size = sizeof(double); data.mv_data = new double; *reinterpret_cast<double*>(data.mv_data) = numberLocal->Value(); freeData = true; } else if (dataHandle->IsBoolean()) { auto booleanLocal = Nan::To<v8::Boolean>(dataHandle).ToLocalChecked(); data.mv_size = sizeof(double); data.mv_data = new bool; *reinterpret_cast<bool*>(data.mv_data) = booleanLocal->Value(); freeData = true; } else { Nan::ThrowError("Invalid data type."); } } int rc = mdb_del(tw->txn, dw->dbi, &key, freeData ? &data : nullptr); if (freeKey) { freeKey(key); } if (freeData) { if (dataHandle->IsString()) { delete[] (uint16_t*)data.mv_data; } else if (node::Buffer::HasInstance(dataHandle)) { // I think the data is owned by the node::Buffer so we don't need to free it - need to clarify } else if (dataHandle->IsNumber()) { delete (double*)data.mv_data; } else if (dataHandle->IsBoolean()) { delete (bool*)data.mv_data; } } if (rc != 0) { return throwLmdbError(rc); } }
NVD-CWE-noinfo
null
522,374
113262016694954010326776401196468291122
null
null
other
node-lmdb
97760104c0fd311206b88aecd91fa1f59fe2b85a
0
NAN_METHOD(TxnWrap::abort) { Nan::HandleScope scope; TxnWrap *tw = Nan::ObjectWrap::Unwrap<TxnWrap>(info.This()); if (!tw->txn) { return Nan::ThrowError("The transaction is already closed."); } mdb_txn_abort(tw->txn); tw->removeFromEnvWrap(); tw->txn = nullptr; }
NVD-CWE-noinfo
null
522,375
313693146167928649072324880144071248063
null
null
other
node-lmdb
97760104c0fd311206b88aecd91fa1f59fe2b85a
0
NAN_METHOD(TxnWrap::ctor) { Nan::HandleScope scope; EnvWrap *ew = Nan::ObjectWrap::Unwrap<EnvWrap>(Local<Object>::Cast(info[0])); int flags = 0; if (info[1]->IsObject()) { Local<Object> options = Local<Object>::Cast(info[1]); // Get flags from options setFlagFromValue(&flags, MDB_RDONLY, "readOnly", false, options); } // Check existence of current write transaction if (0 == (flags & MDB_RDONLY) && ew->currentWriteTxn != nullptr) { return Nan::ThrowError("You have already opened a write transaction in the current process, can't open a second one."); } MDB_txn *txn; int rc = mdb_txn_begin(ew->env, nullptr, flags, &txn); if (rc != 0) { if (rc == EINVAL) { return Nan::ThrowError("Invalid parameter, which on MacOS is often due to more transactions than available robust locked semaphors (see node-lmdb docs for more info)"); } return throwLmdbError(rc); } TxnWrap* tw = new TxnWrap(ew->env, txn); tw->flags = flags; tw->ew = ew; tw->ew->Ref(); tw->Wrap(info.This()); // Set the current write transaction if (0 == (flags & MDB_RDONLY)) { ew->currentWriteTxn = tw; } else { ew->readTxns.push_back(tw); } return info.GetReturnValue().Set(info.This()); }
NVD-CWE-noinfo
null
522,376
130133738190316414134316419765674120458
null
null
other
node-lmdb
97760104c0fd311206b88aecd91fa1f59fe2b85a
0
NAN_METHOD(TxnWrap::getBoolean) { return getCommon(info, valToBoolean); }
NVD-CWE-noinfo
null
522,377
140582431524336829375468712395069094706
null
null
other
node-lmdb
97760104c0fd311206b88aecd91fa1f59fe2b85a
0
NAN_METHOD(TxnWrap::getBinary) { return getCommon(info, valToBinary); }
NVD-CWE-noinfo
null
522,378
115129818850744078520114658161971092253
null
null
other
node-lmdb
97760104c0fd311206b88aecd91fa1f59fe2b85a
0
NAN_METHOD(TxnWrap::commit) { Nan::HandleScope scope; TxnWrap *tw = Nan::ObjectWrap::Unwrap<TxnWrap>(info.This()); if (!tw->txn) { return Nan::ThrowError("The transaction is already closed."); } int rc = mdb_txn_commit(tw->txn); tw->removeFromEnvWrap(); tw->txn = nullptr; if (rc != 0) { return throwLmdbError(rc); } }
NVD-CWE-noinfo
null
522,379
121301977646653559366311180269817451923
null
null
other
node-lmdb
97760104c0fd311206b88aecd91fa1f59fe2b85a
0
void TxnWrap::removeFromEnvWrap() { if (this->ew) { if (this->ew->currentWriteTxn == this) { this->ew->currentWriteTxn = nullptr; } else { auto it = std::find(ew->readTxns.begin(), ew->readTxns.end(), this); if (it != ew->readTxns.end()) { ew->readTxns.erase(it); } } this->ew->Unref(); this->ew = nullptr; } }
NVD-CWE-noinfo
null
522,380
296317506903370523961617565214117428395
null
null
other
node-lmdb
97760104c0fd311206b88aecd91fa1f59fe2b85a
0
Nan::NAN_METHOD_RETURN_TYPE TxnWrap::getCommon(Nan::NAN_METHOD_ARGS_TYPE info, Local<Value> (*successFunc)(MDB_val&)) { Nan::HandleScope scope; if (info.Length() != 2 && info.Length() != 3) { return Nan::ThrowError("Invalid number of arguments to cursor.get"); } TxnWrap *tw = Nan::ObjectWrap::Unwrap<TxnWrap>(info.This()); DbiWrap *dw = Nan::ObjectWrap::Unwrap<DbiWrap>(Local<Object>::Cast(info[0])); if (!tw->txn) { return Nan::ThrowError("The transaction is already closed."); } MDB_val key, oldkey, data; bool keyIsValid; auto keyType = inferAndValidateKeyType(info[1], info[2], dw->keyType, keyIsValid); if (!keyIsValid) { // inferAndValidateKeyType already threw an error return; } auto freeKey = argToKey(info[1], key, keyType, keyIsValid); if (!keyIsValid) { // argToKey already threw an error return; } // Bookkeeping for old key so that we can free it even if key will point inside LMDB oldkey.mv_data = key.mv_data; oldkey.mv_size = key.mv_size; int rc = mdb_get(tw->txn, dw->dbi, &key, &data); if (freeKey) { freeKey(oldkey); } if (rc == MDB_NOTFOUND) { return info.GetReturnValue().Set(Nan::Null()); } else if (rc != 0) { return throwLmdbError(rc); } else { return info.GetReturnValue().Set(successFunc(data)); } }
NVD-CWE-noinfo
null
522,381
211795776106805654192569309739126203417
null
null
other
node-lmdb
97760104c0fd311206b88aecd91fa1f59fe2b85a
0
NAN_METHOD(TxnWrap::getNumber) { return getCommon(info, valToNumber); }
NVD-CWE-noinfo
null
522,382
29985559570653563433965292448894091320
null
null
other
node-lmdb
97760104c0fd311206b88aecd91fa1f59fe2b85a
0
Nan::NAN_METHOD_RETURN_TYPE TxnWrap::putCommon(Nan::NAN_METHOD_ARGS_TYPE info, void (*fillFunc)(Nan::NAN_METHOD_ARGS_TYPE info, MDB_val&), void (*freeData)(MDB_val&)) { Nan::HandleScope scope; if (info.Length() != 3 && info.Length() != 4) { return Nan::ThrowError("Invalid number of arguments to txn.put"); } TxnWrap *tw = Nan::ObjectWrap::Unwrap<TxnWrap>(info.This()); DbiWrap *dw = Nan::ObjectWrap::Unwrap<DbiWrap>(Local<Object>::Cast(info[0])); if (!tw->txn) { return Nan::ThrowError("The transaction is already closed."); } int flags = 0; MDB_val key, data; bool keyIsValid; auto keyType = inferAndValidateKeyType(info[1], info[3], dw->keyType, keyIsValid); if (!keyIsValid) { // inferAndValidateKeyType already threw an error return; } auto freeKey = argToKey(info[1], key, keyType, keyIsValid); if (!keyIsValid) { // argToKey already threw an error return; } if (!info[3]->IsNull() && !info[3]->IsUndefined() && info[3]->IsObject()) { auto options = Local<Object>::Cast(info[3]); setFlagFromValue(&flags, MDB_NODUPDATA, "noDupData", false, options); setFlagFromValue(&flags, MDB_NOOVERWRITE, "noOverwrite", false, options); setFlagFromValue(&flags, MDB_APPEND, "append", false, options); setFlagFromValue(&flags, MDB_APPENDDUP, "appendDup", false, options); // NOTE: does not make sense to support MDB_RESERVE, because it wouldn't save the memcpy from V8 to lmdb } // Fill key and data fillFunc(info, data); // Keep a copy of the original key and data, so we can free them MDB_val originalKey = key; MDB_val originalData = data; int rc = mdb_put(tw->txn, dw->dbi, &key, &data, flags); // Free original key and data (what was supplied by the user, not what points to lmdb) if (freeKey) { freeKey(originalKey); } if (freeData) { freeData(originalData); } // Check result code if (rc != 0) { return throwLmdbError(rc); } }
NVD-CWE-noinfo
null
522,383
327504724290267669545503796104615648541
null
null
other
node-lmdb
97760104c0fd311206b88aecd91fa1f59fe2b85a
0
NAN_METHOD(TxnWrap::putBinary) { return putCommon(info, [](Nan::NAN_METHOD_ARGS_TYPE info, MDB_val &data) -> void { data.mv_size = node::Buffer::Length(info[2]); data.mv_data = node::Buffer::Data(info[2]); }, [](MDB_val &) -> void { // The data is owned by the node::Buffer so we don't need to free it. }); }
NVD-CWE-noinfo
null
522,384
274366162858498806842651231303117952613
null
null
other
node-lmdb
97760104c0fd311206b88aecd91fa1f59fe2b85a
0
NAN_METHOD(TxnWrap::getString) { return getCommon(info, valToString); }
NVD-CWE-noinfo
null
522,385
50804322121229586582284772344515302237
null
null
other
node-lmdb
97760104c0fd311206b88aecd91fa1f59fe2b85a
0
NAN_METHOD(TxnWrap::putBoolean) { return putCommon(info, [](Nan::NAN_METHOD_ARGS_TYPE info, MDB_val &data) -> void { auto booleanLocal = Nan::To<v8::Boolean>(info[2]).ToLocalChecked(); booleanToPut = booleanLocal->Value(); data.mv_size = sizeof(bool); data.mv_data = &booleanToPut; }, nullptr); }
NVD-CWE-noinfo
null
522,386
3239950279361858703082378303053726488
null
null
other
maddy
7ee6a39c6a1939b376545f030a5efd6f90913583
0
static int conv_func(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata_ptr) { *resp = (struct pam_response*)appdata_ptr; return PAM_SUCCESS; }
CWE-613
null
522,442
240159382519350654004395498659051294070
null
null
other
maddy
7ee6a39c6a1939b376545f030a5efd6f90913583
0
struct error_obj run_pam_auth(const char *username, char *password) { // PAM frees pam_response for us. struct pam_response *reply = malloc(sizeof(struct pam_response)); if (reply == NULL) { struct error_obj ret_val; ret_val.status = 2; ret_val.func_name = "malloc"; ret_val.error_msg = "Out of memory"; return ret_val; } reply->resp = password; reply->resp_retcode = 0; const struct pam_conv local_conv = { conv_func, reply }; pam_handle_t *local_auth = NULL; int status = pam_start("maddy", username, &local_conv, &local_auth); if (status != PAM_SUCCESS) { struct error_obj ret_val; ret_val.status = 2; ret_val.func_name = "pam_start"; ret_val.error_msg = pam_strerror(local_auth, status); return ret_val; } status = pam_authenticate(local_auth, PAM_SILENT|PAM_DISALLOW_NULL_AUTHTOK); if (status != PAM_SUCCESS) { struct error_obj ret_val; if (status == PAM_AUTH_ERR || status == PAM_USER_UNKNOWN) { ret_val.status = 1; } else { ret_val.status = 2; } ret_val.func_name = "pam_authenticate"; ret_val.error_msg = pam_strerror(local_auth, status); return ret_val; } status = pam_acct_mgmt(local_auth, PAM_SILENT|PAM_DISALLOW_NULL_AUTHTOK); if (status != PAM_SUCCESS) { struct error_obj ret_val; if (status == PAM_AUTH_ERR || status == PAM_USER_UNKNOWN || status == PAM_NEW_AUTHTOK_REQD) { ret_val.status = 1; } else { ret_val.status = 2; } ret_val.func_name = "pam_acct_mgmt"; ret_val.error_msg = pam_strerror(local_auth, status); return ret_val; } status = pam_end(local_auth, status); if (status != PAM_SUCCESS) { struct error_obj ret_val; ret_val.status = 2; ret_val.func_name = "pam_end"; ret_val.error_msg = pam_strerror(local_auth, status); return ret_val; } struct error_obj ret_val; ret_val.status = 0; ret_val.func_name = NULL; ret_val.error_msg = NULL; return ret_val; }
CWE-613
null
522,443
283443869067414917158176917086877093267
null
null
other