This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug python/21699] New: printf "%s", $_as_string(...) can include characters from the child


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

            Bug ID: 21699
           Summary: printf "%s", $_as_string(...)   can include characters
                    from the child
           Product: gdb
           Version: HEAD
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: python
          Assignee: unassigned at sourceware dot org
          Reporter: mmalcomson.public at gmail dot com
  Target Milestone: ---

Created attachment 10235
  --> https://sourceware.org/bugzilla/attachment.cgi?id=10235&action=edit
Test program

When calling `printf`, the value gets put into the child process and printed
from there.

Python strings coerced to gdb values are not NULL terminated.

Combined, this means that calling the `printf` command with a python string
results in printing a string that isn't NULL terminated in the inferior.
This can hence result in extra junk in the output.

e.g. a session running on the attached program



~ [11:48:23] % share/repos/gdb-source/build/gdb/gdb  -q
--data-directory="/usr/share/gdb" test
Reading symbols from test...done.
(gdb) start
Temporary breakpoint 1 at 0x4004c8: file test.c, line 17.
Starting program: /home/matthew/test 

Temporary breakpoint 1, main () at test.c:17
17        return 0;
(gdb) printf "%s\n", $_as_string("hello")
"hello"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
(gdb) quit
A debugging session is active.

        Inferior 1 [process 13368] will be killed.

Quit anyway? (y or n) y
~ [11:49:07] %

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]