This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[Bug translator/2149] check return value for _stp_map_set_xx()
- From: "eteo at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: systemtap at sources dot redhat dot com
- Date: 23 Apr 2006 04:32:53 -0000
- Subject: [Bug translator/2149] check return value for _stp_map_set_xx()
- References: <20060112181937.2149.hunt@redhat.com>
- Reply-to: sourceware-bugzilla at sourceware dot org
------- Additional Comments From eteo at redhat dot com 2006-04-23 04:32 -------
Before fix, _stp_map_set_xx do not have their return values checked:
[eteo@eteo src]$ stap -DMAXMAPENTRIES=1 -p3 -u -e 'probe begin { a[2]="hello" ;
a[3]="a"} global a' | grep _stp_map_set
_stp_map_set_is (global_a, l->__tmp0, (l->__tmp2[0] ? l->__tmp2 : NULL));
_stp_map_set_is (global_a, l->__tmp4, (l->__tmp6[0] ? l->__tmp6 : NULL));
After applying fix:
[eteo@eteo src]$ stap -DMAXMAPENTRIES=1 -p3 -u -e 'probe begin { a[2]="hello" ;
a[3]="a"} global a' | grep _stp_map_set
{ int rc = _stp_map_set_is (global_a, l->__tmp0, (l->__tmp2[0] ? l->__tmp2
: NULL)); if (unlikely(rc)) c->last_error = "Array overflow, check
MAXMAPENTRIES"; };
{ int rc = _stp_map_set_is (global_a, l->__tmp4, (l->__tmp6[0] ? l->__tmp6
: NULL)); if (unlikely(rc)) c->last_error = "Array overflow, check
MAXMAPENTRIES"; };
[eteo@eteo src]$ stap -DMAXMAPENTRIES=1 -u -e 'probe begin { a[2]="hello" ;
a[3]="a"} global a'
ERROR: Array overflow, check MAXMAPENTRIES near identifier 'a' at <input>:1:30
WARNING: Number of errors: 1, skipped probes: 0
Here's the patch. Please feedback.
Index: ChangeLog
===================================================================
RCS file: /cvs/systemtap/src/ChangeLog,v
retrieving revision 1.360
diff -u -3 -r1.360 ChangeLog
--- ChangeLog 23 Apr 2006 03:28:45 -0000 1.360
+++ ChangeLog 23 Apr 2006 04:24:42 -0000
@@ -1,5 +1,11 @@
2006-04-23 Eugene Teo <eteo@redhat.com>
+ PR 2149
+ * translate.cxx (mapvar::set): Test _stp_map_set_xx() for
+ array overflows.
+
+2006-04-23 Eugene Teo <eteo@redhat.com>
+
* small_demos/ansi_colors.stp: Add an example of using octal
escape sequences to display all possible ansi colors.
Index: translate.cxx
===================================================================
RCS file: /cvs/systemtap/src/translate.cxx,v
retrieving revision 1.114
diff -u -3 -r1.114 translate.cxx
--- translate.cxx 22 Apr 2006 06:46:00 -0000 1.114
+++ translate.cxx 23 Apr 2006 04:24:46 -0000
@@ -581,14 +581,20 @@
string set (vector<tmpvar> const & indices, tmpvar const & val) const
{
+ string res = "{ int rc = ";
+
// impedance matching: empty strings -> NULL
if (type() == pe_string)
- return (call_prefix("set", indices)
+ res += (call_prefix("set", indices)
+ ", (" + val.qname() + "[0] ? " + val.qname() + " : NULL))");
else if (type() == pe_long)
- return (call_prefix("set", indices) + ", " + val.qname() + ")");
+ res += (call_prefix("set", indices) + ", " + val.qname() + ")");
else
throw semantic_error("setting a value of an unsupported map type");
+
+ res += "; if (unlikely(rc)) c->last_error = \"Array overflow, check
MAXMAPENTRIES\"; }";
+
+ return res;
}
string hist() const
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |WAITING
http://sourceware.org/bugzilla/show_bug.cgi?id=2149
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.