From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 136B33858C2C; Thu, 7 Dec 2023 02:50:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 136B33858C2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1701917418; bh=sLW4945G/951z3uz9mwqTVC3C8l7V9QnD+Ti5/QtRs0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=GtbHN6MP3QuL/6l+wIZ0HJ/lvKKX0cj0cnTWMw2GTn8oVfRb1QZVTvopX8nJxw8zb RIQtiggAzkKOzkpq28dMVMbn0V15a47/TSqZ+xHhXyyjY3MUOmcJVr+sHZNUHt3yMz w+aR9CQQNKYbiXXqoF/58nOhQmNcNeEM+ODXKAKE= From: "lijunlong at openresty dot com" To: systemtap@sourceware.org Subject: [Bug translator/31119] did not escape Golang program symbol name Date: Thu, 07 Dec 2023 02:50:17 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: systemtap X-Bugzilla-Component: translator X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: lijunlong at openresty dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: systemtap at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31119 --- Comment #1 from lijunlong --- Comment on attachment 15242 --> https://sourceware.org/bugzilla/attachment.cgi?id=3D15242 did not escape golang symbol commit d10ae580f8791606739ae6bfa7db7277d6921cc9 Author: lijunlong Date: Thu Dec 7 10:49:37 2023 +0800 bugfix: escape char should cast to 'unsigned char' instead of 'unsigned= '. diff --git a/util.cxx b/util.cxx index f2eaf54f4..7a1081654 100644 --- a/util.cxx +++ b/util.cxx @@ -1301,10 +1301,9 @@ octal_character (unsigned c) return '0' + c % 8; } -string -escaped_character (unsigned c) +static inline void +escaped_character_impl (unsigned c, ostringstream &o) { - ostringstream o; int oc =3D (int)c; switch (oc) @@ -1362,18 +1361,28 @@ escaped_character (unsigned c) << octal_character(oc); } } +} + +string +escaped_character (unsigned c) +{ + ostringstream o; + + escaped_character_impl(c, o); + return o.str(); } string escaped_literal_string (const string& str) { - string op; + ostringstream o; + for (unsigned i =3D 0; i < str.size (); i++) { - op +=3D escaped_character((unsigned)str[i]); + escaped_character_impl((unsigned char)str[i], o); } - return op; + return o.str(); } string --=20 You are receiving this mail because: You are the assignee for the bug.=