From patchwork Tue Dec 19 18:41:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 851002 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-88372-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="uC7CzLD5"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3z1RZz1xFZz9sNr for ; Wed, 20 Dec 2017 05:42:03 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=Kgg2nRzakRlkGW7flQlAIjVfJHv9N ywoT56JYVnO+E25KE5T37Vn8QwSJgwyXobLhL26smlQIqBgrgJJi3gWhcfNh6CGZ fAFrk7pWIiKFH+UtkjTxWGvs4D84/1aI+TGVcqJlWho3oiCEEyuzNBPqNpTX5tJ5 bC8euRpavEU67M= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=5g9a9Z1ZsjwussdhkJSK26xD1ww=; b=uC7 CzLD5TsoN9iCP7OBChFSn9SstMQw5HdSFHd8NTLosyyHO3ArdczovoLI8UlQFEZ3 JX0qTItsVHSacPTF2lBww+mgmiNGm/gWz857bmUsUmLR8b+eivo5J/8sVWMImveT z9nGf6G7ddEt42uK/hkk9nFSBtwDTuGnm3b70BHI= Received: (qmail 87089 invoked by alias); 19 Dec 2017 18:41:52 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 86305 invoked by uid 89); 19 Dec 2017 18:41:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Date: Tue, 19 Dec 2017 18:41:45 +0000 From: Joseph Myers To: Subject: Avoid signed shift overflow in pow (bug 21309) [committed] Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) As noted in bug 21309, dbl-64/e_pow.c contains signed int shifts that, although the shift count is in the range [0, 31], shift bits into and beyond the sign bit and so are undefined in ISO C. Although this is defined in GNU C, this patch from the bug cleans up the code to avoid those shifts. Tested for x86_64. Committed. 2017-12-19 Bernd Edlinger [BZ #21309] * sysdeps/ieee754/dbl-64/e_pow.c (checkint): Make m and n unsigned. diff --git a/sysdeps/ieee754/dbl-64/e_pow.c b/sysdeps/ieee754/dbl-64/e_pow.c index 2eb8dbf..d3cb42d 100644 --- a/sysdeps/ieee754/dbl-64/e_pow.c +++ b/sysdeps/ieee754/dbl-64/e_pow.c @@ -452,7 +452,8 @@ checkint (double x) int4 i[2]; double x; } u; - int k, m, n; + int k; + unsigned int m, n; u.x = x; m = u.i[HIGH_HALF] & 0x7fffffff; /* no sign */ if (m >= 0x7ff00000)