This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH][gdb] fix unsigned overflow in charset.c
- From: Pedro Alves <palves at redhat dot com>
- To: Paul Koning <paulkoning at comcast dot net>, gdb-patches at sourceware dot org
- Date: Tue, 9 Oct 2018 18:31:48 +0100
- Subject: Re: [PATCH][gdb] fix unsigned overflow in charset.c
- References: <7B48D309-445E-4141-A87A-1F3D5FA70EFD@comcast.net>
On 10/09/2018 06:19 PM, Paul Koning wrote:
> This fixed an overflow in pointer arithmetic that crashes GDB on Mac OS.
_unsigned_ overflow? That isn't undefined. Do we really want to trap
those? I don't think GCC's version does that.
From:
https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#silencing-unsigned-integer-overflow
seems like there's a way to disable it.
Thanks,
Pedro Alves
>
> Ok for trunk?
>
> paul
>
> gdb/ChangeLog:
>
> 2018-10-09 Paul Koning <paul_koning@dell.com>
>
> * charset.c (convert_between_encodings): Fix unsigned overflow.
>
> diff --git a/gdb/charset.c b/gdb/charset.c
> index 8bb2b4d669..64757ab279 100644
> --- a/gdb/charset.c
> +++ b/gdb/charset.c
> @@ -548,7 +548,7 @@ convert_between_encodings (const char *from, const char *to,
>
> /* Now make sure that the object on the obstack only includes
> bytes we have converted. */
> - obstack_blank_fast (output, -outleft);
> + obstack_blank_fast (output, -(ssize_t) outleft);
>
> if (r == (size_t) -1)
> {
>