From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 3580C488AC for ; Tue, 19 Dec 2023 13:43:08 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C1A9568D129; Tue, 19 Dec 2023 15:43:05 +0200 (EET) Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 26D4E68D000 for ; Tue, 19 Dec 2023 15:42:59 +0200 (EET) Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-5c701bd98f3so1613477a12.1 for ; Tue, 19 Dec 2023 05:42:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702993376; x=1703598176; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=1PyAy1DnMuAiFaf9m5gkfm9QUGPz2SfExh2wK3eBib4=; b=dArVPMZWiCf/zNsBAoKd1srwvgMYxiJrX6MJji7rEfKbMoM6p4TPYbEbsl5oknPsIV BQmr4feDS9UZa3cOVgXOSggEHeghNUJbbI1/WKypytX0aGVjDQiXeAoYKIG0ywUMCdYO umMJ0VISf4A2u4fXjLa09fip7D3diRlMBfQzfpoKP4Ow2alcUrhjNYYjzOrCJlZL5flK c/zDdVdqxkzohvRyjigIjIZOH2CXUCO2voKbgAQOchIIxLZAV9sJfhKrp3/LRGPFEEkv nA9h7tmj4NXk9tfT/EVv+BIx82S2s5A1bADBu/mi1pCgJGoteuy722Ui0whc76foB/DD OjPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702993376; x=1703598176; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1PyAy1DnMuAiFaf9m5gkfm9QUGPz2SfExh2wK3eBib4=; b=j0zoF4YR/Wi3EHLg39oXVYWxJwKUCkwgnWraWhSJ10V52Ki/EZ4RqPE9p4c4iqbM47 WYKkGOQMtyLT2+Toru1QukhVP4m2EjcjDLd4ZR7Pt8CNzl1bd+cLD7pNxgLZRgyPvDKl 6YzoJOqU5cktJjdD6eTfGnUHb4R8y4UY2kcC7twnr/SZoXusJd4pdPkyBWyuVsBdW731 SOgkqdPxuJEGVcmFQveF+f04nGbocSmU08BmxRYY9mZ1fGOFSYK2FZ/6AEHlFuh0rQC7 PtgOZV7A9ZP9qvSaMXDDhuOmfH+c4AqNJtTYIzuCi+SG8nqijiow2y16UiRrBmBHcrhs guaQ== X-Gm-Message-State: AOJu0YzxEh0MDvq7C3H1ue/1TrGLSvrb++gTxAL5SSCC/k4LBtamPcGJ reapvef81ggd1p5Ipj5ACl/pbf1SjNU= X-Google-Smtp-Source: AGHT+IGhppViI04spJVRONBUhOvOVLzumSCE6NoVQXA9DaubV81RETacS7un4YnDypzthhcQBCaZjQ== X-Received: by 2002:a05:6a20:938b:b0:190:3d3c:6590 with SMTP id x11-20020a056a20938b00b001903d3c6590mr9363849pzh.62.1702993376200; Tue, 19 Dec 2023 05:42:56 -0800 (PST) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id j12-20020a170902c3cc00b001d3c3d486bfsm3340787plj.163.2023.12.19.05.42.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 05:42:55 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Tue, 19 Dec 2023 10:42:50 -0300 Message-ID: <20231219134250.140-1-jamrial@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] ffmpeg_mux_init: use strtoll() to parse stream and group indexes X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Long is 32 bits signed on Windows, and nb_stream{s,_groups} are both unsigned int. In a realistic scenario this wont make a difference, but it's still proper. Also ensure the parsed string is an integer while at it. Signed-off-by: James Almer --- fftools/ffmpeg_mux_init.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index cca7baf79e..bdda93a569 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -2147,12 +2147,13 @@ static int of_parse_iamf_submixes(Muxer *mux, AVStreamGroup *stg, char *ptr) if (element) { AVIAMFSubmixElement *submix_element; + char *endptr = NULL; int64_t idx = -1; if (e = av_dict_get(dict, "stg", NULL, 0)) - idx = strtol(e->value, NULL, 0); + idx = strtoll(e->value, &endptr, 0); av_dict_set(&dict, "stg", NULL, 0); - if (idx < 0 || idx >= oc->nb_stream_groups - 1 || + if (!endptr || *endptr || idx < 0 || idx >= oc->nb_stream_groups - 1 || oc->stream_groups[idx]->type != AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT) { av_log(mux, AV_LOG_ERROR, "Invalid or missing stream group index in " "submix element specification \"%s\"\n", subtoken); @@ -2268,8 +2269,9 @@ static int of_parse_group_token(Muxer *mux, const char *token, char *ptr) e = NULL; while (e = av_dict_get(dict, "st", e, 0)) { - int64_t idx = strtol(e->value, NULL, 0); - if (idx < 0 || idx >= oc->nb_streams) { + char *endptr; + int64_t idx = strtoll(e->value, &endptr, 0); + if (*endptr || idx < 0 || idx >= oc->nb_streams) { av_log(mux, AV_LOG_ERROR, "Invalid stream index %"PRId64"\n", idx); ret = AVERROR(EINVAL); goto end; @@ -2279,8 +2281,9 @@ static int of_parse_group_token(Muxer *mux, const char *token, char *ptr) goto end; } while (e = av_dict_get(dict, "stg", e, 0)) { - int64_t idx = strtol(e->value, NULL, 0); - if (idx < 0 || idx >= oc->nb_stream_groups - 1) { + char *endptr; + int64_t idx = strtoll(e->value, &endptr, 0); + if (*endptr || idx < 0 || idx >= oc->nb_stream_groups - 1) { av_log(mux, AV_LOG_ERROR, "Invalid stream group index %"PRId64"\n", idx); ret = AVERROR(EINVAL); goto end; -- 2.43.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".