This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
src/gdb ChangeLog charset.c target.c
- From: palves at sourceware dot org
- To: gdb-cvs at sourceware dot org
- Date: 11 Mar 2013 12:22:20 -0000
- Subject: src/gdb ChangeLog charset.c target.c
CVSROOT: /cvs/src
Module name: src
Changes by: palves@sourceware.org 2013-03-11 12:22:20
Modified files:
gdb : ChangeLog charset.c target.c
Log message:
Avoid invalid pointer to pointer conversions.
Casts between 'char **' <-> 'unsigned char **' and 'char **' <-> const
char **' are actually invalid:
http://gcc.gnu.org/ml/gcc-help/2013-03/msg00118.html
In a nutshell, char (and variants) can alias anything, but pointers to
chars get no special treatment (cf. C99/N1256, 6.5/7).
Turns out older gcc's actually warn/complain on these constructs,
though newer one's don't:
http://sourceware.org/ml/gdb-patches/2013-03/msg00429.html
http://sourceware.org/ml/gdb-patches/2013-03/msg00430.html
This patch fixes the cases I added last week. It also fixes one other
preexisting case in charset.c, though it seems even older gccs don't
complain of char * <-> const char * aliasing.
Tested on x86_64 Fedora 17.
gdb/
2013-03-11 Pedro Alves <palves@redhat.com>
* charset.c (convert_between_encodings): Don't cast between
different pointer to pointer types. Instead, make the 'inp' local
be of the type iconv expects.
(wchar_iterate): Don't cast between different pointer to pointer
types. Instead, use new pointer local of the type iconv expects.
* target.c (target_read_stralloc, target_fileio_read_stralloc):
Add new local of type char pointer, and use it to get a
char/string view of the byte buffer, instead of casting between
pointer to pointer types.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.15252&r2=1.15253
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/charset.c.diff?cvsroot=src&r1=1.54&r2=1.55
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/target.c.diff?cvsroot=src&r1=1.328&r2=1.329