diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2002-04-23 20:15:04 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2002-04-23 20:15:04 (GMT) |
commit | d95efe4257b7d7aa95e273c2cb206b1d72c57cad (patch) | |
tree | ae01a808a27df000d819bd0aff5bb28eeffab14c /Modules/resource.c | |
parent | ed9e453eb78a73b6f5b72aa4ecdbf1b091fa9c55 (diff) | |
download | cpython-d95efe4257b7d7aa95e273c2cb206b1d72c57cad.zip cpython-d95efe4257b7d7aa95e273c2cb206b1d72c57cad.tar.gz cpython-d95efe4257b7d7aa95e273c2cb206b1d72c57cad.tar.bz2 |
Check for overflow errors in setrlimit(),
and reflow a long line.
Diffstat (limited to 'Modules/resource.c')
-rw-r--r-- | Modules/resource.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Modules/resource.c b/Modules/resource.c index 4d8d4fa..9881314 100644 --- a/Modules/resource.c +++ b/Modules/resource.c @@ -142,7 +142,8 @@ resource_setrlimit(PyObject *self, PyObject *args) int resource; PyObject *curobj, *maxobj; - if (!PyArg_ParseTuple(args, "i(OO):setrlimit", &resource, &curobj, &maxobj)) + if (!PyArg_ParseTuple(args, "i(OO):setrlimit", + &resource, &curobj, &maxobj)) return NULL; if (resource < 0 || resource >= RLIM_NLIMITS) { @@ -153,13 +154,21 @@ resource_setrlimit(PyObject *self, PyObject *args) #if !defined(HAVE_LARGEFILE_SUPPORT) rl.rlim_cur = PyInt_AsLong(curobj); + if (rl.rlim_cur == -1 && PyErr_Occurred()) + return NULL; rl.rlim_max = PyInt_AsLong(maxobj); + if (rl.rlim_max == -1 && PyErr_Occurred()) + return NULL; #else /* The limits are probably bigger than a long */ rl.rlim_cur = PyLong_Check(curobj) ? PyLong_AsLongLong(curobj) : PyInt_AsLong(curobj); + if (rl.rlim_cur == -1 && PyErr_Occurred()) + return NULL; rl.rlim_max = PyLong_Check(maxobj) ? PyLong_AsLongLong(maxobj) : PyInt_AsLong(maxobj); + if (rl.rlim_max == -1 && PyErr_Occurred()) + return NULL; #endif rl.rlim_cur = rl.rlim_cur & RLIM_INFINITY; |