From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16151 invoked by alias); 9 Oct 2018 17:31:53 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 16142 invoked by uid 89); 9 Oct 2018 17:31:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 09 Oct 2018 17:31:51 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 383518125C; Tue, 9 Oct 2018 17:31:50 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A51C7A017; Tue, 9 Oct 2018 17:31:49 +0000 (UTC) Subject: Re: [PATCH][gdb] fix unsigned overflow in charset.c To: Paul Koning , gdb-patches@sourceware.org References: <7B48D309-445E-4141-A87A-1F3D5FA70EFD@comcast.net> From: Pedro Alves Message-ID: <1acace4a-a5c6-abaf-f070-9c2e6768b6f2@redhat.com> Date: Tue, 09 Oct 2018 17:31:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <7B48D309-445E-4141-A87A-1F3D5FA70EFD@comcast.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-10/txt/msg00221.txt.bz2 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 > > * 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) > { >