public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [Bug translator/31119] New: did not escape Golang program symbol name
@ 2023-12-07  0:44 lijunlong at openresty dot com
  2023-12-07  2:50 ` [Bug translator/31119] " lijunlong at openresty dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: lijunlong at openresty dot com @ 2023-12-07  0:44 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=31119

            Bug ID: 31119
           Summary: did not escape Golang program symbol name
           Product: systemtap
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: translator
          Assignee: systemtap at sourceware dot org
          Reporter: lijunlong at openresty dot com
  Target Milestone: ---

Created attachment 15242
  --> https://sourceware.org/bugzilla/attachment.cgi?id=15242&action=edit
did not escape golang symbol

1. golang's symbol name may contain double quotation marks.

For example:
```
<386a40>   DW_AT_name        : *struct { Rates map[string]float64
"json:\"rate_by_service\"" }

```

2. get char from cpp string singed extended would get the wrong result.

```
(unsigned)str[I] is equal to (unsigned)(int)str[i]
```

We need to change to (unsigned char)str[i]

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug translator/31119] did not escape Golang program symbol name
  2023-12-07  0:44 [Bug translator/31119] New: did not escape Golang program symbol name lijunlong at openresty dot com
@ 2023-12-07  2:50 ` lijunlong at openresty dot com
  2023-12-07  2:50 ` lijunlong at openresty dot com
  2023-12-13 15:35 ` wcohen at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: lijunlong at openresty dot com @ 2023-12-07  2:50 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=31119

--- Comment #1 from lijunlong <lijunlong at openresty dot com> ---
Comment on attachment 15242
  --> https://sourceware.org/bugzilla/attachment.cgi?id=15242
did not escape golang symbol

commit d10ae580f8791606739ae6bfa7db7277d6921cc9
Author: lijunlong <lijunlong@openresty.com>
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 = (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 = 0; i < str.size (); i++)
     {
-      op += escaped_character((unsigned)str[i]);
+      escaped_character_impl((unsigned char)str[i], o);
     }
-  return op;
+  return o.str();
 }

 string

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug translator/31119] did not escape Golang program symbol name
  2023-12-07  0:44 [Bug translator/31119] New: did not escape Golang program symbol name lijunlong at openresty dot com
  2023-12-07  2:50 ` [Bug translator/31119] " lijunlong at openresty dot com
@ 2023-12-07  2:50 ` lijunlong at openresty dot com
  2023-12-13 15:35 ` wcohen at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: lijunlong at openresty dot com @ 2023-12-07  2:50 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=31119

--- Comment #2 from lijunlong <lijunlong at openresty dot com> ---
Comment on attachment 15242
  --> https://sourceware.org/bugzilla/attachment.cgi?id=15242
did not escape golang symbol

commit d10ae580f8791606739ae6bfa7db7277d6921cc9
Author: lijunlong <lijunlong@openresty.com>
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 = (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 = 0; i < str.size (); i++)
     {
-      op += escaped_character((unsigned)str[i]);
+      escaped_character_impl((unsigned char)str[i], o);
     }
-  return op;
+  return o.str();
 }

 string

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug translator/31119] did not escape Golang program symbol name
  2023-12-07  0:44 [Bug translator/31119] New: did not escape Golang program symbol name lijunlong at openresty dot com
  2023-12-07  2:50 ` [Bug translator/31119] " lijunlong at openresty dot com
  2023-12-07  2:50 ` lijunlong at openresty dot com
@ 2023-12-13 15:35 ` wcohen at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: wcohen at redhat dot com @ 2023-12-13 15:35 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=31119

William Cohen <wcohen at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wcohen at redhat dot com

--- Comment #3 from William Cohen <wcohen at redhat dot com> ---
Could you provide a simple go program reproducer for this?

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-13 15:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-07  0:44 [Bug translator/31119] New: did not escape Golang program symbol name lijunlong at openresty dot com
2023-12-07  2:50 ` [Bug translator/31119] " lijunlong at openresty dot com
2023-12-07  2:50 ` lijunlong at openresty dot com
2023-12-13 15:35 ` wcohen at redhat dot com

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 read-only IMAP folder(s) and NNTP newsgroup(s).