This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug python/21699] New: printf "%s", $_as_string(...) can include characters from the child
- From: "mmalcomson.public at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Sun, 02 Jul 2017 10:53:23 +0000
- Subject: [Bug python/21699] New: printf "%s", $_as_string(...) can include characters from the child
- Auto-submitted: auto-generated
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.