From: Jerome Marchand <jmarchan@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>,
Johannes Berg <johannes@sipsolutions.net>,
Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Subject: trace-cmd library: suspicious SWIG instructions for the python wrappers
Date: Thu, 20 Jun 2024 10:49:19 +0200 [thread overview]
Message-ID: <112290ac-ee9c-41a9-8f20-17406364741e@redhat.com> (raw)
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
reply other threads:[~2024-06-20 8:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=112290ac-ee9c-41a9-8f20-17406364741e@redhat.com \
--to=jmarchan@redhat.com \
--cc=johannes@sipsolutions.net \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).