summaryrefslogtreecommitdiff
path: root/psutil/_psutil_linux.c
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2015-08-07 13:49:33 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2015-08-07 13:49:33 +0200
commit3226e941cebd784f75af9bbc0d5ad13f635a1695 (patch)
tree1c4980105dfcb6f7abbc2137b96c2faaeaac10c2 /psutil/_psutil_linux.c
parent5df3b81eb8383b2f533de37311e386aede444305 (diff)
downloadpsutil-3226e941cebd784f75af9bbc0d5ad13f635a1695.tar.gz
fix #513: [Linux] fixed integer overflow for RLIM_INFINITY.
Diffstat (limited to 'psutil/_psutil_linux.c')
-rw-r--r--psutil/_psutil_linux.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/psutil/_psutil_linux.c b/psutil/_psutil_linux.c
index 5c365939..697c81b0 100644
--- a/psutil/_psutil_linux.c
+++ b/psutil/_psutil_linux.c
@@ -638,7 +638,6 @@ void init_psutil_linux(void)
PyModule_AddIntConstant(module, "version", PSUTIL_VERSION);
#if PSUTIL_HAVE_PRLIMIT
- PyModule_AddIntConstant(module, "RLIM_INFINITY", RLIM_INFINITY);
PyModule_AddIntConstant(module, "RLIMIT_AS", RLIMIT_AS);
PyModule_AddIntConstant(module, "RLIMIT_CORE", RLIMIT_CORE);
PyModule_AddIntConstant(module, "RLIMIT_CPU", RLIMIT_CPU);
@@ -650,6 +649,20 @@ void init_psutil_linux(void)
PyModule_AddIntConstant(module, "RLIMIT_NPROC", RLIMIT_NPROC);
PyModule_AddIntConstant(module, "RLIMIT_RSS", RLIMIT_RSS);
PyModule_AddIntConstant(module, "RLIMIT_STACK", RLIMIT_STACK);
+
+ PyObject *v;
+#if defined(HAVE_LONG_LONG)
+ if (sizeof(RLIM_INFINITY) > sizeof(long)) {
+ v = PyLong_FromLongLong((PY_LONG_LONG) RLIM_INFINITY);
+ } else
+#endif
+ {
+ v = PyLong_FromLong((long) RLIM_INFINITY);
+ }
+ if (v) {
+ PyModule_AddObject(module, "RLIM_INFINITY", v);
+ }
+
#ifdef RLIMIT_MSGQUEUE
PyModule_AddIntConstant(module, "RLIMIT_MSGQUEUE", RLIMIT_MSGQUEUE);
#endif