Fixed: SDBM deadlock

This commit is contained in:
Breno Silva
2013-04-04 12:36:59 -04:00
parent 3bd497946e
commit c30bb6d6df

View File

@@ -490,7 +490,12 @@ int collection_store(modsec_rec *msr, apr_table_t *col) {
/* Now generate the binary object. */ /* Now generate the binary object. */
blob = apr_pcalloc(msr->mp, blob_size); blob = apr_pcalloc(msr->mp, blob_size);
if (blob == NULL) { if (blob == NULL) {
goto error; if (dbm != NULL) {
apr_sdbm_unlock(dbm);
apr_sdbm_close(dbm);
}
return -1;
} }
blob[0] = 0x49; blob[0] = 0x49;
@@ -543,9 +548,15 @@ int collection_store(modsec_rec *msr, apr_table_t *col) {
if (rc != APR_SUCCESS) { if (rc != APR_SUCCESS) {
msr_log(msr, 1, "collection_store: Failed to write to DBM file \"%s\": %s", dbm_filename, msr_log(msr, 1, "collection_store: Failed to write to DBM file \"%s\": %s", dbm_filename,
get_apr_error(msr->mp, rc)); get_apr_error(msr->mp, rc));
goto error; if (dbm != NULL) {
apr_sdbm_unlock(dbm);
apr_sdbm_close(dbm);
} }
return -1;
}
apr_sdbm_unlock(dbm);
apr_sdbm_close(dbm); apr_sdbm_close(dbm);
if (msr->txcfg->debuglog_level >= 4) { if (msr->txcfg->debuglog_level >= 4) {
@@ -557,11 +568,6 @@ int collection_store(modsec_rec *msr, apr_table_t *col) {
return 0; return 0;
error: error:
if (dbm) {
apr_sdbm_close(dbm);
}
return -1; return -1;
} }