summaryrefslogtreecommitdiff
path: root/hw/arm/omap1.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2014-05-13 16:09:39 +0100
committerPeter Maydell <peter.maydell@linaro.org>2014-05-13 16:09:39 +0100
commit7e7e5858f83ae711b08d11e2268c6fc6f8385fb7 (patch)
tree329a6e931144270326a6fafe1be946d0ecda080d /hw/arm/omap1.c
parentc94239fe5633fb9816b5bbc61ccc134ce7171b2b (diff)
downloadqemu-7e7e5858f83ae711b08d11e2268c6fc6f8385fb7.tar.gz
qemu-7e7e5858f83ae711b08d11e2268c6fc6f8385fb7.tar.bz2
qemu-7e7e5858f83ae711b08d11e2268c6fc6f8385fb7.zip
hw/arm/omap1: Avoid unintended sign extension writing omap_rtc YEARS_REG
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 <peter.maydell@linaro.org> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Diffstat (limited to 'hw/arm/omap1.c')
-rw-r--r--hw/arm/omap1.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/hw/arm/omap1.c b/hw/arm/omap1.c
index b433748c60..b28e0521b4 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;