Fix parameter parsing for omniOBpy setClientCallTimeout, setClientThreadCallTimeout, setClientConnectTimeout

Glen Walker via omniORB-list <[email protected]> Wed, 31 Jan 2018 16:32:48 +1300
Newsgroups gmane.comp.corba.omniorb.user
Message-ID <CAEPKXsF0J0j6ska7qWFmunSQJgK1jYd729QO9RUiD-PYkJf_rA@mail.gmail.com>
The C++ API for omniORB contains the functions

namespace omniORB {
  void setClientCallTimeout(CORBA::ULong millisecs);
  void setClientCallTimeout(CORBA::Object_ptr obj, CORBA::ULong millisecs);
  void setClientThreadCallTimeout(CORBA::ULong millisecs);
  void setClientConnectTimeout(CORBA::ULong millisecs);
};

and the Python API for omniORB contains the corresponding functions

omniORB.setClientCallTimeout(millisecs)
omniORB.setClientCallTimeout(objref, millisecs)
omniORB.setClientThreadCallTimeout(millisecs)
omniORB.setClientConnectTimeout(millisecs)

however omniORBpy is parsing the millisecs parameter as a signed integer
instead of an unsigned long. This leads to incorrect timeouts if values
over 2^31 - 1 are used. Admittedly this is only a problem for timeouts of
over 24.9 days, which should be uncommon, and we only noticed the issue
when debugging a problem where we had multipled a timeout in seconds by
1000 more that once.

Attached is a patch to fix the issue. Note that it uses "k" to parse the
unsigned long, which was introduced in Python 2.3, and will be a problem if
omniORBpy still supports earlier versions.

Cheers,
Glen

_______________________________________________
omniORB-list mailing list
[email protected]
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
pyomniFunc.cc.patch (application/octet-stream, 1.4 KB)
--- omniORBpy/modules/pyomniFunc.cc	2017-02-21 11:45:59.000000000 +1300
+++ pyomniFunc.cc	2018-01-30 16:22:34.710101000 +1300
@@ -718,15 +718,15 @@
   static PyObject* pyomni_setClientCallTimeout(PyObject* self, PyObject* args)
   {
     if (PyTuple_GET_SIZE(args) == 1) {
-      int timeout;
-      if (!PyArg_ParseTuple(args, (char*)"i", &timeout))
+      unsigned long timeout;
+      if (!PyArg_ParseTuple(args, (char*)"k", &timeout))
 	return 0;
       omniORB::setClientCallTimeout(timeout);
     }
     else {
-      int timeout;
+      unsigned long timeout;
       PyObject* pyobjref;
-      if (!PyArg_ParseTuple(args, (char*)"Oi", &pyobjref, &timeout))
+      if (!PyArg_ParseTuple(args, (char*)"Ok", &pyobjref, &timeout))
 	return 0;
 
       CORBA::Object_ptr objref = omniPy::getObjRef(pyobjref);
@@ -747,8 +747,8 @@
   static PyObject* pyomni_setClientThreadCallTimeout(PyObject* self,
 						     PyObject* args)
   {
-    int timeout;
-    if (!PyArg_ParseTuple(args, (char*)"i", &timeout))
+    unsigned long timeout;
+    if (!PyArg_ParseTuple(args, (char*)"k", &timeout))
       return 0;
 
     try {
@@ -795,8 +795,8 @@
   static PyObject* pyomni_setClientConnectTimeout(PyObject* self,
 						  PyObject* args)
   {
-    int timeout;
-    if (!PyArg_ParseTuple(args, (char*)"i", &timeout))
+    unsigned long timeout;
+    if (!PyArg_ParseTuple(args, (char*)"k", &timeout))
       return 0;
 
     omniORB::setClientConnectTimeout(timeout);