From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 0EDB54EF65 for ; Fri, 20 Feb 2026 15:04:44 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'xuBOdlcjIBYwwdvvskXoGOxfJ5Xx7dKvoEQVpd6u8rU=', expected b'jQkcMgxR2QwVJ7wvaBup/8VjwXAuaAF+YINRALAhclY=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1771599875; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=xuBOdlcjIBYwwdvvskXoGOxfJ5Xx7dKvoEQVpd6u8rU=; b=tzjGd59P1veCzP32gEDzI/HBKAdPpucIcixg6EF+2Mzl7tOQF5kgUKvSAFtrwjmUAo0LZ B1DFyV86n6PK55EV/rj+gkNxUivsx6NckOC543wCmul0uO8kL8QBmRcmVmsoVxnbJqna1b2 To3aznf4nRcgUee4lS2RbwS8alPREOyN6Ex2xdfICqGZx3EBX7B/siadvGdv8iClXC6X0Mv wh/slQFrMY0SdfvPF2yZmKd52osUpKuNnhv8f7GS1hQXHfPnz3tgo94EeXm46Zjz+ayqlSl xs43wFpHPBVHh0rmb0XQksbnHHfnBzCvcNKOzVhVLY8EwfRo+3ry44mGrk3Q== Received: from [172.18.0.3] (unknown [172.18.0.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id ED9F3691329; Fri, 20 Feb 2026 17:04:35 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1771599862; b=RXCxRxfdhfF3Ui87eJUvWua+gslI5lEWFt2t659OfrqhGemZS2RAtkWVZzjV+wfka378X XMwap2FizFPU5pb0cHgoFVzVpksytzFjumB9U8ZCkJCFaZKSHsW+bICeE1r69uDYMYl8aiy TvaTkianKzoFLXBKMmm4SVChXhDKFDjQbEKSVF1DDP6c4toP2oTs4f4wo5sKBJkELIiejNU RRaqPbh7pnQiZ4mUi3NJVrjLPaeCnZC+ueIT/1S1MPg8qqDaIivplJ9HWTzL7sRDFE6lgBF ua3Wsep0bxIL0c+fu3D74gu5Do1g1SP1eyEomeZS8uxPDo2JmId2wRpiQiEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1771599862; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=qOreBHvC/od89whC1nwY2zxpl0laXfdLFLGQvrIunlA=; b=Yf9peAcw6gpjFtyKjdndGh20viXQwvE7jJ7wjIuM3VxBy5L5SrVQ6xw68Y6RIK4vXlp3O 5SbR7mwnRWuouDLMCx/252tU+3flU9Ruz1Qq3WxCzfvg2zdUMg5rDS/iiAoZHFwYMhCCzPw 2DPijR1UutJL+3iYwqODO59szL9Zthq+xf6om6G0fWz+7F2iSIH6HXUrDcmUsJSb/uhnMoo 5aWl9g68E2RSu4NO19/6yidW3CuD0Q3Zr4Ll7c0LFkz3TvbO47waXECIi59kH0fD3UQl7p4 3r7A/KUR8neiCa6GIu8UxAznD2cQwBGtHWSViBTU9rBwpJLyaEaxdyLhTudw== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1771599855; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=jQkcMgxR2QwVJ7wvaBup/8VjwXAuaAF+YINRALAhclY=; b=LWGJGEgMVH11IKeOVyb7Jk8exAXVhETLY2WNh5VnK5ILZsqL1Z5yojti+3XRTx0PgLBsr gtc4Z7XepiBIEiYZmd3+G+yuiUqFrUq1b3zy7Aqbiz2SdqIGOtq8vg8Y+SzJq0TTuigLDUF aKm53G77p7jY36lBrroq0EjRQKZBGvL6shtyJx1bMknLnq7qi0X/CKqI7waHcTQ7nV1/pbX a1P1nIwRvUnrO6hVw3bFx5LMLAn8zZw2OmBlreVj1Rq8+2rTUSKcl0fB14+caOaUp3u7aJ+ FrjFOmKX92H4KD0Ho1VA9iqoBb5T36j2LyLcHZxyjv8mcXQyXMJdT5iLKETQ== MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Fri, 20 Feb 2026 15:04:14 -0000 Message-ID: <177159985516.25.18100310809163895623@29965ddac10e> Message-ID-Hash: MFAWLJSPKQUY6VJBQVRU3R3767JQMRKW X-Message-ID-Hash: MFAWLJSPKQUY6VJBQVRU3R3767JQMRKW X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PR] swscale/ops: avoid UB in ff_sws_pixel_expand() (PR #21814) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Niklas Haas via ffmpeg-devel Cc: Niklas Haas Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #21814 opened by Niklas Haas (haasn) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21814 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21814.patch Restructure the loop slightly to avoid UB in the first loop iteration if src is 4 bytes, which otherwise computes (0 << 32) | 1. Instead, make 1 the default base case and only shift+add if src < dst. >>From ca0e3c6b9281d559ea52cacdc8ba7260b85d1e41 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Fri, 20 Feb 2026 16:02:32 +0100 Subject: [PATCH] swscale/ops: avoid UB in ff_sws_pixel_expand() Restructure the loop slightly to avoid UB in the first loop iteration if src is 4 bytes, which otherwise computes (0 << 32) | 1. Instead, make 1 the default base case and only shift+add if src < dst. --- libswscale/ops_internal.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libswscale/ops_internal.h b/libswscale/ops_internal.h index ba4c9b39da..c2e23f664a 100644 --- a/libswscale/ops_internal.h +++ b/libswscale/ops_internal.h @@ -31,9 +31,9 @@ static inline AVRational ff_sws_pixel_expand(SwsPixelType from, SwsPixelType to) { const int src = ff_sws_pixel_type_size(from); const int dst = ff_sws_pixel_type_size(to); - int scale = 0; - for (int i = 0; i < dst / src; i++) - scale = scale << src * 8 | 1; + int scale = 1; + for (int i = 1; i < dst / src; i++) + scale = (scale << (src * 8)) | 1; return Q(scale); } -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org