From patchwork Tue May 31 17:28:58 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1685 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:54:22 -0000 Delivered-To: patches@linaro.org Received: by 10.52.110.9 with SMTP id hw9cs303129vdb; Tue, 31 May 2011 10:29:03 -0700 (PDT) Received: by 10.216.142.13 with SMTP id h13mr6380372wej.42.1306862942191; Tue, 31 May 2011 10:29:02 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk [81.2.115.146]) by mx.google.com with ESMTPS id i57si647833wed.111.2011.05.31.10.29.00 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 31 May 2011 10:29:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1QRSkU-0003V4-1f; Tue, 31 May 2011 18:28:58 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, malc , =?UTF-8?q?Juha=20Riihim=C3=A4ki?= , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [PATCH] audio: fix integer overflow expression Date: Tue, 31 May 2011 18:28:58 +0100 Message-Id: <1306862938-13431-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 MIME-Version: 1.0 From: Juha Riihimäki Fix an integer overflow that can happen for signed 32 bit types when using FLOAT_MIXENG. (Note that at the moment this is only true when using the MacOSX coreaudio audio driver.) Signed-off-by: Juha Riihimäki Reviewed-by: Peter Maydell --- I'm trying to get random patches out of my patch-stack and upstream. This one looks "obviously correct" but it only kicks in for MacOSX and coreaudio, and I don't have access to that platform to test myself, so treat my reviewed-by accordingly. This has actually been posted here before, last year: http://patchwork.ozlabs.org/patch/48703/ audio/mixeng_template.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/mixeng_template.h b/audio/mixeng_template.h index a2d0ef8..e01da0a 100644 --- a/audio/mixeng_template.h +++ b/audio/mixeng_template.h @@ -46,7 +46,7 @@ static mixeng_real inline glue (conv_, ET) (IN_T v) #endif #else /* !RECIPROCAL */ #ifdef SIGNED - return nv / (mixeng_real) (IN_MAX - IN_MIN); + return nv / (mixeng_real) ((mixeng_real)IN_MAX - (mixeng_real)IN_MIN); #else return (nv - HALF) / (mixeng_real) IN_MAX; #endif @@ -63,7 +63,7 @@ static IN_T inline glue (clip_, ET) (mixeng_real v) } #ifdef SIGNED - return ENDIAN_CONVERT ((IN_T) (v * (IN_MAX - IN_MIN))); + return ENDIAN_CONVERT ((IN_T) (v * ((mixeng_real)IN_MAX - (mixeng_real)IN_MIN))); #else return ENDIAN_CONVERT ((IN_T) ((v * IN_MAX) + HALF)); #endif