summaryrefslogtreecommitdiff
path: root/Modules/resource.c
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2002-04-23 20:15:04 +0000
committerJeremy Hylton <jeremy@alum.mit.edu>2002-04-23 20:15:04 +0000
commitd95efe4257b7d7aa95e273c2cb206b1d72c57cad (patch)
treeae01a808a27df000d819bd0aff5bb28eeffab14c /Modules/resource.c
parented9e453eb78a73b6f5b72aa4ecdbf1b091fa9c55 (diff)
downloadcpython-git-d95efe4257b7d7aa95e273c2cb206b1d72c57cad.tar.gz
Check for overflow errors in setrlimit(),
and reflow a long line.
Diffstat (limited to 'Modules/resource.c')
-rw-r--r--Modules/resource.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/Modules/resource.c b/Modules/resource.c
index 4d8d4faa01..9881314c1e 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;