From patchwork Mon Jan 14 23:29:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 11756 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 1C48D44E7D0 for ; Tue, 15 Jan 2019 01:30:50 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4447368A947; Tue, 15 Jan 2019 01:30:38 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe05-1.mx.upcmail.net (vie01a-dmta-pe05-1.mx.upcmail.net [84.116.36.11]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7AFF468A91C for ; Tue, 15 Jan 2019 01:30:30 +0200 (EET) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe05.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1gjBgq-00088s-0h for ffmpeg-devel@ffmpeg.org; Tue, 15 Jan 2019 00:30:44 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id jBfsgySAL2WSsjBfsgJICG; Tue, 15 Jan 2019 00:29:44 +0100 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.41.20 X-CNFS-Analysis: v=2.3 cv=E7kcWpVl c=1 sm=1 tr=0 a=I1eytVlZLDX1BM2VTtTtSw==:117 a=I1eytVlZLDX1BM2VTtTtSw==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=nZOtpAppAAAA:20 a=poY9Q88S6bJDmcyQWdYA:9 a=pHzHmUro8NiASowvMSCR:22 a=nt3jZW36AmriUCFCBwmW:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 15 Jan 2019 00:29:43 +0100 Message-Id: <20190114232943.10560-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190114232943.10560-1-michael@niedermayer.cc> References: <20190114232943.10560-1-michael@niedermayer.cc> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfDrap9TopxgVF/NdM9H5xLB0bFogN6HDVE2yvzsAPsHLXH5+hSSmLEb0yvXDYmAiuadTrU2wSMTRo1XxxYH5AhobQx1ApFnCyZlsW0dokHRLV232Gwgo jM0gtWk70uCGCSOkg9/jYCMjaf+s0Rs8f4xYWWvSiT04xvkRWpjGAq7J Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/ilbcdec: Fix undefined integer overflow lsf2poly() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The addition is moved up into the context where the variable is unsigned avoiding the undefined behavior Fixes: runtime error: signed integer overflow: 2147481972 + 4096 cannot be represented in type 'int' Fixes: 12444/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ILBC_fuzzer-5755706244857856 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/ilbcdec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/ilbcdec.c b/libavcodec/ilbcdec.c index 643547f4ab..bba83a5896 100644 --- a/libavcodec/ilbcdec.c +++ b/libavcodec/ilbcdec.c @@ -408,11 +408,11 @@ static void lsf2poly(int16_t *a, int16_t *lsf) a[0] = 4096; for (i = 5; i > 0; i--) { - tmp = f[0][6 - i] + (unsigned)f[1][6 - i]; - a[6 - i] = (tmp + 4096) >> 13; + tmp = f[0][6 - i] + (unsigned)f[1][6 - i] + 4096; + a[6 - i] = tmp >> 13; - tmp = f[0][6 - i] - (unsigned)f[1][6 - i]; - a[5 + i] = (tmp + 4096) >> 13; + tmp = f[0][6 - i] - (unsigned)f[1][6 - i] + 4096; + a[5 + i] = tmp >> 13; } }