[Bug tapsets/25686] New: user_buffer_quoted incorrectly octal-escapes non-printable characters

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug tapsets/25686] New: user_buffer_quoted incorrectly octal-escapes non-printable characters

Sourceware - systemtap mailing list
https://sourceware.org/bugzilla/show_bug.cgi?id=25686

            Bug ID: 25686
           Summary: user_buffer_quoted incorrectly octal-escapes
                    non-printable characters
           Product: systemtap
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: tapsets
          Assignee: systemtap at sourceware dot org
          Reporter: craig.ringer at 2ndquadrant dot com
  Target Milestone: ---

`user_buffer_quoted` omits leading zeroes from octal escapes even when the next
character is a printable digit. This leads to incorrectly escaped data.

E.g. given the buffer `1\x006\x00` i.e. hex-representation `31 00 36 00`,
`user_buffer_quoted` will emit `1\06\0`. This will decode to hex-bytes `31 06
00` because the sequence `\06` is interpreted as "octal 06" not "octal 0, then
ascii printable digit 6".

The underlying bug appears to be in `_stp_text_str`.

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug tapsets/25686] user_buffer_quoted incorrectly octal-escapes non-printable characters

Sourceware - systemtap mailing list
https://sourceware.org/bugzilla/show_bug.cgi?id=25686

--- Comment #1 from Craig Ringer <craig.ringer at 2ndquadrant dot com> ---
Created attachment 12383
  --> https://sourceware.org/bugzilla/attachment.cgi?id=12383&action=edit
Proposed patch to fix ambiguous octacl escapes

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug tapsets/25686] user_buffer_quoted incorrectly octal-escapes non-printable characters

Sourceware - systemtap mailing list
In reply to this post by Sourceware - systemtap mailing list
https://sourceware.org/bugzilla/show_bug.cgi?id=25686

--- Comment #2 from Craig Ringer <craig.ringer at 2ndquadrant dot com> ---
Proposed patch attached

```
Author: Craig Ringer <[hidden email]>
Date:   Tue Mar 17 22:20:56 2020 +0800

    Fix ambiguous octal escapes in _stp_text_str

    Tapset functions like user_buffer_quoted that use the _stp_text_str
function
    for octal escaping would produce incorrect output if a null byte was
followed
    by a byte that represents a printable digit in US-ASCII. The null byte
would
    be emitted in the shorthand \0 form, then the printable digit would be
emitted
    literally, resulting in (e.g.) \06 instead of \0006 for the two input bytes
    "0x00 0x06".

    Fix by disabling shorthand escapes for null bytes. The alternatives are to:

    (a) look ahead in the buffer to see if the next byte is a digit and only
        expand the \0 to \000 if it would be ambiguous; or
    (b) octal-escape all printable digits

    The second would be woeful for the intended function of human-readable-ish
    buffer representations. The former seems potentially fragile and risky,
    so I just went with simple.

    Fixes bug #25686
```

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug tapsets/25686] user_buffer_quoted incorrectly octal-escapes non-printable characters

Sourceware - systemtap mailing list
In reply to this post by Sourceware - systemtap mailing list
https://sourceware.org/bugzilla/show_bug.cgi?id=25686

Craig Ringer <craig.ringer at 2ndquadrant dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://sourceware.org/bugz
                   |                            |illa/show_bug.cgi?id=11277

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug tapsets/25686] user_buffer_quoted incorrectly octal-escapes non-printable characters

Sourceware - systemtap mailing list
In reply to this post by Sourceware - systemtap mailing list
https://sourceware.org/bugzilla/show_bug.cgi?id=25686

Frank Ch. Eigler <fche at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fche at redhat dot com
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Frank Ch. Eigler <fche at redhat dot com> ---
Thanks for your patience, merged!

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