From patchwork Thu Sep 19 22:16:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 15156 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 D94824483B9 for ; Fri, 20 Sep 2019 01:24:32 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B83FA689D6C; Fri, 20 Sep 2019 01:24:32 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 918B468824C for ; Fri, 20 Sep 2019 01:24:25 +0300 (EEST) Received: by mail-wm1-f68.google.com with SMTP id y21so149443wmi.0 for ; Thu, 19 Sep 2019 15:24:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aXVeCCNfwMBmghXRFGgMt1Lc/Ma9aTs4pG6GFKx83nc=; b=M/zJ5bgwkBPiJIZEo2jm5K/Pp1TRU1UU1fItH+28bjpo+0gZUD8Tqgu+oVBe0BfJzk B4vC48ZQgoRVGCGMUGmLnpGckPY80H6QEZ4RCijONEwfvnsiCVSv1ZpZ/1IH1aHCBhck FQURUGatx0EnXK/7RfoxS24JORPJakSkpzAtGZrGLtyUlt4n1y6K4zmKh7oKJ8wOM7Ci dKJJGwCIL+HWnzNJtLWd+ClAfiK5zlKSM/g3ErI1+A6VShDeRZuGxRqur7AfneW7LCMv jTzLtjjMs+DlaYfYbGNRRe/OC473B73kMeCidbE6IoYIefO8Hk4PD0MNM+DztrKZYlcp RjAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aXVeCCNfwMBmghXRFGgMt1Lc/Ma9aTs4pG6GFKx83nc=; b=Vpo99zszURU93RTcpr8fB9deFhIg/ZeIkJZ2zVDO6iDXBbsGafi3tRg1DUU3ThD53F lAdL0g+/GNBA+EsOIAOoyLdA4r8gEAJ/kPSu9chi2+iwMO5ih8JU+hNs6np4QFc+VeWi 5mk8Yx/tE8iwzIpAFlBMaZZB2zSYwPn4ECTSAaR6dmMqpWUOXHbGLkMV0XoNueBgo/kn objyCdSeUIyGn8t3CFxFY2dxg2WOBelN9LcW5N06pTDX50M0tT41k+t8sj1glmFUJSSj rZqFWAzD9bI0/36uGWYZBDGgzcGLozLNuixSJlj09NyxVOvilmX8UdPbkHwFCTei4mN5 IfeQ== X-Gm-Message-State: APjAAAXtE4189P6Y0DaPL8g4Ytp+mOAK+Uo4bKYiNJIrIYu49FbPRg6I 0W725EJH7O8Fu1RQViejxY7rXaav X-Google-Smtp-Source: APXvYqzVGteJExslPL0Sy19diN/HRpCsLeXU//1NuRkseQ/uPiww5fEm/1rVj122jFwvYspIR91HdA== X-Received: by 2002:a1c:c589:: with SMTP id v131mr91830wmf.163.1568931864947; Thu, 19 Sep 2019 15:24:24 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc0f857.dynamic.kabel-deutschland.de. [188.192.248.87]) by smtp.gmail.com with ESMTPSA id y12sm49955wrn.74.2019.09.19.15.24.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 15:24:24 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 20 Sep 2019 00:16:56 +0200 Message-Id: <20190919221706.16529-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190919221706.16529-1-andreas.rheinhardt@gmail.com> References: <20190919221706.16529-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/11] avformat/sdsdec: Fix undefined shifts 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" An uint8_t gets promoted to an int before left shifting, so that it is subject to the usual restrictions of signed types wrt shifts. Given that the destination is an unsigned, simply convert to unsigned before shifting. Fixes tickets #8163, #8164 and #8165. Signed-off-by: Andreas Rheinhardt --- libavformat/sdsdec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/sdsdec.c b/libavformat/sdsdec.c index 9c361cdff2..adc7d02a4d 100644 --- a/libavformat/sdsdec.c +++ b/libavformat/sdsdec.c @@ -43,7 +43,7 @@ static void byte2_read(const uint8_t *src, uint32_t *dst) int i; for (i = 0; i < 120; i += 2) { - unsigned sample = (src[i + 0] << 25) + (src[i + 1] << 18); + unsigned sample = ((unsigned)src[i + 0] << 25) + (src[i + 1] << 18); dst[i / 2] = sample; } @@ -56,7 +56,7 @@ static void byte3_read(const uint8_t *src, uint32_t *dst) for (i = 0; i < 120; i += 3) { unsigned sample; - sample = (src[i + 0] << 25) | (src[i + 1] << 18) | (src[i + 2] << 11); + sample = ((unsigned)src[i + 0] << 25) | (src[i + 1] << 18) | (src[i + 2] << 11); dst[i / 3] = sample; } } @@ -68,7 +68,7 @@ static void byte4_read(const uint8_t *src, uint32_t *dst) for (i = 0; i < 120; i += 4) { unsigned sample; - sample = (src[i + 0] << 25) | (src[i + 1] << 18) | (src[i + 2] << 11) | (src[i + 3] << 4); + sample = ((unsigned)src[i + 0] << 25) | (src[i + 1] << 18) | (src[i + 2] << 11) | (src[i + 3] << 4); dst[i / 4] = sample; } }