piersharding / python-sapnwrfc

SAP RFC Connector using the SAP NW RFC SDK for Python
http://www.piersharding.com/blog/
GNU Lesser General Public License v2.1
26 stars 9 forks source link

segfault if you supply the wrong data type #2

Closed guettli closed 13 years ago

guettli commented 13 years ago

I get a segmentation fault, if there is wrong data type

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7b07c20 in PyString_FromFormatV () from /usr/lib64/libpython2.6.so.1.0
(gdb) bt
#0  0x00007ffff7b07c20 in PyString_FromFormatV () from /usr/lib64/libpython2.6.so.1.0
#1  0x00007ffff7b2d941 in PyErr_Format () from /usr/lib64/libpython2.6.so.1.0
#2  0x00007ffff6a526b2 in SAPNW_rfc_call_error1 (msg=, part1=) at src/nwsaprfcutil.c:232
#3  0x00007ffff6a555df in set_char_value (hcont=0xc67d00, name=0x7fffffffb770, value=, max=) at src/nwsaprfcutil.c:1427
#4  0x00007ffff6a55fb7 in set_field_value (hcont=, fieldDesc=..., value=0x61c298) at src/nwsaprfcutil.c:1708
#5  0x00007ffff6a56620 in set_structure_value (hcont=, name=0xbdae40, value=0xd3ecb0) at src/nwsaprfcutil.c:1679
#6  0x00007ffff6a569ef in set_parameter_value (fptr=0xcce530, name=0xc255e0, value=0xd3ecb0) at src/nwsaprfcutil.c:1907
#7  0x00007ffff6a56bc7 in sapnwrfc_invoke (self=) at src/nwsaprfcutil.c:2009
#8  0x00007ffff7b2166c in PyEval_EvalFrameEx () from /usr/lib64/libpython2.6.so.1.0
#9  0x00007ffff7b2381b in PyEval_EvalFrameEx () from /usr/lib64/libpython2.6.so.1.0
#10 0x00007ffff7b26441 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.6.so.1.0
#11 0x00007ffff7b2104d in PyEval_EvalFrameEx () from /usr/lib64/libpython2.6.so.1.0
#12 0x00007ffff7b2381b in PyEval_EvalFrameEx () from /usr/lib64/libpython2.6.so.1.0
#13 0x00007ffff7b26441 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.6.so.1.0
#14 0x00007ffff7b1fa32 in PyEval_EvalCode () from /usr/lib64/libpython2.6.so.1.0
#15 0x00007ffff7b3a7a1 in ?? () from /usr/lib64/libpython2.6.so.1.0
#16 0x00007ffff7b3aba4 in PyRun_FileExFlags () from /usr/lib64/libpython2.6.so.1.0
#17 0x00007ffff7b3b299 in PyRun_SimpleFileExFlags () from /usr/lib64/libpython2.6.so.1.0
#18 0x00007ffff7b42638 in Py_Main () from /usr/lib64/libpython2.6.so.1.0
#19 0x00007ffff6e8eb7d in __libc_start_main () from /lib64/libc.so.6
#20 0x00000000004006e9 in _start ()
(gdb) quit

here is my patch

diff --git a/src/nwsaprfcutil.c b/src/nwsaprfcutil.c
index 8957c18..aca803b 100644
--- a/src/nwsaprfcutil.c
+++ b/src/nwsaprfcutil.c
@@ -1424,7 +1424,7 @@ void set_char_value(DATA_CONTAINER_HANDLE hcont, SAP_UC *name, PyObject * value,
    SAP_UC *p_value;

    if (! PyString_Check(value)){
-           SAPNW_rfc_call_error1("RfcSetChar invalid Input value type:", PyString_AsString(value));
+     SAPNW_rfc_call_error1("RfcSetChar invalid Input value type:", PyString_AsString(PyObject_Repr(value)));
        return;
    }

piersharding commented 13 years ago

Hi - thanks for the patch. I've applied it to master.

Cheers, Piers Harding.