From patchwork Thu May 8 18:46:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 29850 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f72.google.com (mail-qa0-f72.google.com [209.85.216.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D0695202DD for ; Thu, 8 May 2014 18:47:02 +0000 (UTC) Received: by mail-qa0-f72.google.com with SMTP id hw13sf7448466qab.11 for ; Thu, 08 May 2014 11:47:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=zdxQW+zoLlpWs7GPjxCZqfhAoy8Ac0bfXRlMW22k7RI=; b=FRtyrcM4HReSZgcHXIYl7nQDVmC3fNHa8tpdPEems9TSgJiwEAURp6XHKvJ1r6keuz LDDQ+3LHlWRgbOUEC/HIFKX9XVh8v4jyrYhetia8nmYDTPB9O2yAlaVXJXhck90kGD0Z P7nLCxYdFdxva+LbCJ/OlH6G3XK6tEUnOlMcQ+AIGa+Q4TKc6CR/gaIRQunf38sN/HRw vIlxwWeUwHm+nlOy/PPUe78GoCAGOE37+eSdQb8yLnkoGN0wTbsTPkHewmIMnjyoh3EI at1G9/hpD6zymz+aQ5xBQLQU8edptGFVwdYR2SrF6aYzMHrJjdyUH7YY0ZJgdias9s9d QcdA== X-Gm-Message-State: ALoCoQkUrlw2bZt71idC1QFMhV3hDa9C3huH+NGAM1I7cpy+6zHCZ/49KbqtlBkE+NpdkXz5w9FX X-Received: by 10.236.159.200 with SMTP id s48mr2182067yhk.11.1399574822400; Thu, 08 May 2014 11:47:02 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.93.11 with SMTP id c11ls3941752qge.55.gmail; Thu, 08 May 2014 11:47:02 -0700 (PDT) X-Received: by 10.52.15.1 with SMTP id t1mr2122708vdc.49.1399574822243; Thu, 08 May 2014 11:47:02 -0700 (PDT) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id s7si318222vev.110.2014.05.08.11.47.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 08 May 2014 11:47:02 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id pa12so3790951veb.4 for ; Thu, 08 May 2014 11:47:02 -0700 (PDT) X-Received: by 10.58.169.97 with SMTP id ad1mr2072269vec.45.1399574822091; Thu, 08 May 2014 11:47:02 -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.221.72 with SMTP id ib8csp17011vcb; Thu, 8 May 2014 11:47:01 -0700 (PDT) X-Received: by 10.180.160.166 with SMTP id xl6mr4836094wib.42.1399574821342; Thu, 08 May 2014 11:47:01 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id ea8si95745wic.63.2014.05.08.11.47.00 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 08 May 2014 11:47:01 -0700 (PDT) Received-SPF: none (google.com: pm215@archaic.org.uk does not designate permitted sender hosts) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1WiTLO-00052n-Pu; Thu, 08 May 2014 19:46:58 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Peter Crosthwaite Subject: [PATCH 4/8] hw/arm/omap1: Avoid unintended sign extension writing omap_rtc YEARS_REG Date: Thu, 8 May 2014 19:46:54 +0100 Message-Id: <1399574818-19349-5-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1399574818-19349-1-git-send-email-peter.maydell@linaro.org> References: <1399574818-19349-1-git-send-email-peter.maydell@linaro.org> 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: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) 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: , When writing to the YEARS_REG register, if the year value is 99 then the multiplication by 31536000 will overflow into the sign bit of a 32 bit value and then be erroneously sign-extended if time_t is 64 bits. Add a cast to avoid this. Signed-off-by: Peter Maydell Reviewed-by: Peter Crosthwaite --- hw/arm/omap1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/arm/omap1.c b/hw/arm/omap1.c index b433748..b28e052 100644 --- a/hw/arm/omap1.c +++ b/hw/arm/omap1.c @@ -2709,8 +2709,8 @@ static void omap_rtc_write(void *opaque, hwaddr addr, s->ti += ti[1]; } else { /* A less accurate version */ - s->ti -= (s->current_tm.tm_year % 100) * 31536000; - s->ti += from_bcd(value) * 31536000; + s->ti -= (time_t)(s->current_tm.tm_year % 100) * 31536000; + s->ti += (time_t)from_bcd(value) * 31536000; } return;