From patchwork Fri Aug 23 16:36:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 19498 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gh0-f197.google.com (mail-gh0-f197.google.com [209.85.160.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4DAE7248E6 for ; Fri, 23 Aug 2013 16:36:52 +0000 (UTC) Received: by mail-gh0-f197.google.com with SMTP id r20sf633931ghr.4 for ; Fri, 23 Aug 2013 09:36:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=kvECOx/LX3Fv9F0NUEbAdBrK6NgqXlHfTbEobAFSpVg=; b=YMCDEmlz60+jG3Yxhixyq22yEQ6s3+89ubssvT+ZjqlEU94rcKRgCvxtFE4YzNh2RO TUk7Kt8utNedovNhu07594YW7HwTGWuwiSh0koFlH0McJhwp3qP0wsUSz0RX3AwHwKjA OfIRyMazeQw/xQXje5hC95h8Jy6BzImv+8xaEtG4gW3GgUIf/9n43iv9jLUBDG13bUej Jz33l8/GC8wuRTdme1+m6CqWNzMEZMsRfvRPxp4u6MW3NsWumBV+GCevsLfW80QvOmX8 dpOUoZBQ5JyiPMEkpOfEu11xsuMths1M8YaPdweoR+zVd7CHGrQYtf/8/XTKftGU02LM 1iEg== X-Received: by 10.58.206.33 with SMTP id ll1mr63753vec.10.1377275811921; Fri, 23 Aug 2013 09:36:51 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.27.195 with SMTP id v3ls1630776qeg.6.gmail; Fri, 23 Aug 2013 09:36:51 -0700 (PDT) X-Received: by 10.52.103.35 with SMTP id ft3mr244052vdb.5.1377275811770; Fri, 23 Aug 2013 09:36:51 -0700 (PDT) Received: from mail-vb0-f53.google.com (mail-vb0-f53.google.com [209.85.212.53]) by mx.google.com with ESMTPS id fw17si196690vec.28.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Aug 2013 09:36:51 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.53 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.53; Received: by mail-vb0-f53.google.com with SMTP id i3so567587vbh.26 for ; Fri, 23 Aug 2013 09:36:51 -0700 (PDT) X-Gm-Message-State: ALoCoQlUBuUkJ/pqG8/gAnk4WN3J/fc42WLTr3I8Ygc8iambPzPQVOWjsabB6eG6xICLXyj5UsTx X-Received: by 10.220.206.195 with SMTP id fv3mr274301vcb.15.1377275811529; Fri, 23 Aug 2013 09:36:51 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp102834vcz; Fri, 23 Aug 2013 09:36:51 -0700 (PDT) X-Received: by 10.180.205.236 with SMTP id lj12mr410553wic.22.1377275810433; Fri, 23 Aug 2013 09:36:50 -0700 (PDT) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id we3si339914wjb.1.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 23 Aug 2013 09:36:50 -0700 (PDT) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1VCuLw-0002Lu-LD; Fri, 23 Aug 2013 17:36:48 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, qemu-trivial@nongnu.org, Jan Kiszka Subject: [PATCH] slirp/arp_table.c: Avoid shifting into sign bit of signed integers Date: Fri, 23 Aug 2013 17:36:48 +0100 Message-Id: <1377275808-9017-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.53 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , "0xf << 28" shifts right into the sign bit, since 0xf is a signed integer. Use the 'U' suffix to force an unsigned shift to avoid this undefined behaviour and a clang sanitizer warning. Signed-off-by: Peter Maydell Reviewed-by: Eric Blake Acked-by: Jan Kiszka --- slirp/arp_table.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slirp/arp_table.c b/slirp/arp_table.c index bf698c1..ecdb0ba 100644 --- a/slirp/arp_table.c +++ b/slirp/arp_table.c @@ -38,7 +38,7 @@ void arp_table_add(Slirp *slirp, uint32_t ip_addr, uint8_t ethaddr[ETH_ALEN]) ethaddr[3], ethaddr[4], ethaddr[5])); /* Check 0.0.0.0/8 invalid source-only addresses */ - if ((ip_addr & htonl(~(0xf << 28))) == 0) { + if ((ip_addr & htonl(~(0xfU << 28))) == 0) { return; } @@ -74,7 +74,7 @@ bool arp_table_search(Slirp *slirp, uint32_t ip_addr, DEBUG_ARG("ip = 0x%x", ip_addr); /* Check 0.0.0.0/8 invalid source-only addresses */ - assert((ip_addr & htonl(~(0xf << 28))) != 0); + assert((ip_addr & htonl(~(0xfU << 28))) != 0); /* If broadcast address */ if (ip_addr == 0xffffffff || ip_addr == broadcast_addr) {