]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Reject float as uid or gid.
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 10 Feb 2013 21:28:02 +0000 (23:28 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 10 Feb 2013 21:28:02 +0000 (23:28 +0200)
A regression was introduced in the commit for issue issue #4591.

Modules/posixmodule.c

index 7e36df5da6a283154f23ba113549c88fe5fce95e..91352d4d4c488f8dd1d5b95fbfce46c209960643 100644 (file)
@@ -437,7 +437,13 @@ int
 _Py_Uid_Converter(PyObject *obj, void *p)
 {
     int overflow;
-    long result = PyLong_AsLongAndOverflow(obj, &overflow);
+    long result;
+    if (PyFloat_Check(obj)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "integer argument expected, got float");
+        return 0;
+    }
+    result = PyLong_AsLongAndOverflow(obj, &overflow);
     if (overflow < 0)
         goto OverflowDown;
     if (!overflow && result == -1) {
@@ -485,7 +491,13 @@ int
 _Py_Gid_Converter(PyObject *obj, void *p)
 {
     int overflow;
-    long result = PyLong_AsLongAndOverflow(obj, &overflow);
+    long result;
+    if (PyFloat_Check(obj)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "integer argument expected, got float");
+        return 0;
+    }
+    result = PyLong_AsLongAndOverflow(obj, &overflow);
     if (overflow < 0)
         goto OverflowDown;
     if (!overflow && result == -1) {