Skip to content

Commit

Permalink
Fixed MODPYTHON-58
Browse files Browse the repository at this point in the history
Index for mutex passed to _global_lock, _global_unlock, _global_trylock is now checked to make sure it is in appropriate range.
  • Loading branch information
jgallacher committed Jun 26, 2005
1 parent 56f772f commit d50e4e8
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/_apachemodule.c
Expand Up @@ -380,6 +380,14 @@ static PyObject *_global_lock(PyObject *self, PyObject *args)
apr_pool_userdata_get((void **)&glb, MP_CONFIG_KEY,
s->process->pool);

if ((index >= (glb->nlocks)) || (index < -1)) {
ap_log_error(APLOG_MARK, APLOG_WARNING, 0, s,
"Index %d is out of range for number of global mutex locks", index);
PyErr_SetString(PyExc_ValueError,
"Lock index is out of range for number of global mutex locks");
return NULL;
}

if (index == -1) {

int hash = PyObject_Hash(key);
Expand Down Expand Up @@ -446,7 +454,15 @@ static PyObject *_global_trylock(PyObject *self, PyObject *args)

apr_pool_userdata_get((void **)&glb, MP_CONFIG_KEY,
s->process->pool);


if ((index >= (glb->nlocks)) || (index < -1)) {
ap_log_error(APLOG_MARK, APLOG_WARNING, 0, s,
"Index %d is out of range for number of global mutex locks", index);
PyErr_SetString(PyExc_ValueError,
"Lock index is out of range for number of global mutex locks");
return NULL;
}

if (index == -1) {

int hash = PyObject_Hash(key);
Expand Down Expand Up @@ -521,7 +537,15 @@ static PyObject *_global_unlock(PyObject *self, PyObject *args)

apr_pool_userdata_get((void **)&glb, MP_CONFIG_KEY,
s->process->pool);


if ((index >= (glb->nlocks)) || (index < -1)) {
ap_log_error(APLOG_MARK, APLOG_WARNING, 0, s,
"Index %d is out of range for number of global mutex locks", index);
PyErr_SetString(PyExc_ValueError,
"Lock index is out of range for number of global mutex locks");
return NULL;
}

if (index == -1) {

int hash = PyObject_Hash(key);
Expand Down

0 comments on commit d50e4e8

Please sign in to comment.