From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7843 invoked by alias); 23 Apr 2006 04:32:58 -0000 Received: (qmail 7819 invoked by uid 48); 23 Apr 2006 04:32:53 -0000 Date: Sun, 23 Apr 2006 04:32:00 -0000 Message-ID: <20060423043253.7818.qmail@sourceware.org> From: "eteo at redhat dot com" To: systemtap@sources.redhat.com In-Reply-To: <20060112181937.2149.hunt@redhat.com> References: <20060112181937.2149.hunt@redhat.com> Reply-To: sourceware-bugzilla@sourceware.org Subject: [Bug translator/2149] check return value for _stp_map_set_xx() X-Bugzilla-Reason: AssignedTo Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2006-q2/txt/msg00204.txt.bz2 ------- 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 :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 + PR 2149 + * translate.cxx (mapvar::set): Test _stp_map_set_xx() for + array overflows. + +2006-04-23 Eugene Teo + * 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 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.