trace-cmd library: suspicious SWIG instructions for the python wrappers
Jerome Marchand <[email protected]>
| Newsgroups | org.kernel.vger.linux-trace-devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
Static analysis also showed the following error:
Error: UNINIT (CWE-457):
trace-cmd-v3.2/python/ctracecmd_wrap.c:18170: var_decl: Declaring
variable "temp3" without initializer.
trace-cmd-v3.2/python/ctracecmd_wrap.c:18175: assign: Assigning: "arg3"
= "&temp3", which points to uninitialized data.
trace-cmd-v3.2/python/ctracecmd_wrap.c:18188: uninit_use_in_call: Using
uninitialized value "*arg3" when calling "tep_plugin_kvm_get_func".
#18186| }
#18187| arg2 = (struct tep_record *)(argp2);
#18188|-> result = (char *)tep_plugin_kvm_get_func(arg1,arg2,arg3);
#18189| resultobj = SWIG_FromCharPtr((const char *)result);
#18190| if (SWIG_IsTmpObj(res3)) {
AFAICT, this is because of the following line in ctracecmd.i:
%apply unsigned long long *OUTPUT {unsigned long long *}
IIUC, it tells SWIG that all unsigned long long* are to be treated as
output parameter so the wrapping code generated by SWIG doesn't bother
to copy it's value which would definitely explain the uninitialized
use warning above. Also I checked that removing that line produce code
that don't use arg3 uninitialized.
The next line in ctracecmd.i is just as suspicious:
%apply int *OUTPUT {int *}
I have no previous experience with SWIG and I don't understand what
the original intent was when those lines were added, so I don't know
how to fix it.
Regards,
Jerome