From patchwork Tue Mar 2 10:38:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26059 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 B974E44AA0D for ; Tue, 2 Mar 2021 12:39:01 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8647068A6F0; Tue, 2 Mar 2021 12:39:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6A59E689E14 for ; Tue, 2 Mar 2021 12:38:55 +0200 (EET) Received: by mail-ej1-f46.google.com with SMTP id r17so34263219ejy.13 for ; Tue, 02 Mar 2021 02:38:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:reply-to:mime-version :content-transfer-encoding; bh=/aifc3EAM8YYHFKFLSjBSDF6YXI4rAdtNtChe2A4DSM=; b=EgALfEPWaK2AQvlG78B/CgMYNFyDvgy2KItuO2wD3QCFBs7LNKzBo8ZqRv0kaa/RHb 59GAzj+U2Z77O6d+xInd0QnZR7YOf5+L3wHo7zrjKHrwcTCmdo3n8UsFpC3rqnYZK5u/ GzK5iycuWEIvhE8XwMM71SgY+SKhkxvZIIlBoEsygDbd9jgXUrltflSYTVCuDrpVnLhS JTsOwDyA7Oto0pgjFu0583rElEESMXl1LsopIFyOt+0LwjddTQIsS2ol7CKoUeZZNb70 2Yz1J6QYtitaviKW8LQBg6/wKYismREkN9UQwW6X8iUWN2t+pKCXYDMe3vlV021PMtvW bNQw== 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:reply-to :mime-version:content-transfer-encoding; bh=/aifc3EAM8YYHFKFLSjBSDF6YXI4rAdtNtChe2A4DSM=; b=eO6IIT5Xo7NlkOdfyOZYUmUf8NNanbpqcFX6fvv9t3Xtk/ttSQ5XmP6vpsQBbkL8ON qaK0L0+P+kHBeY/xTyM6nDTYYmMYBgwcU9BqRdrPSrd7av6vDfTfSc3cWv53EcbgdjL9 H4DHImONWEa70WKGaV+yUpd73cGSdV/YYgwWfELqp117SMUEUD0nyFykw59fjbMgfugC 9IJejlbZAmh2gglzggywZG+MIIaGBn3zVR/1o3DCBMKVERfQ9fWkuXw+ZxIjE8afHnIr md02DOHjuva/pAHc9HX3ZsyoyQhnSP4/1MQZPQMAdzrBD/AII8mt5NbUdabSZUOC/SQl 4G1g== X-Gm-Message-State: AOAM5335FqWgzOUIgIxMNIyrWUfXGZxh+w4vIz2PQlVPYZjYEq7Y02od nFMt6igmeTE4O2S/EKSginy7uRar9iU= X-Google-Smtp-Source: ABdhPJzD4SacloLtACPSfBr/xi/FOPDNOC/vNX4AJtbJLeqWGcucLvJBbnsDQgCeMCSFtiKQxE58HQ== X-Received: by 2002:a17:907:7692:: with SMTP id jv18mr5017472ejc.475.1614681534650; Tue, 02 Mar 2021 02:38:54 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id u18sm17272534ejc.76.2021.03.02.02.38.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 02:38:54 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 2 Mar 2021 11:38:47 +0100 Message-Id: <20210302103848.483203-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avformat/dashdec: Ensure strings are zero-terminated 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" strncpy only ensures that one does not write beyond the end of the destination buffer; in case of truncation it does not zero-terminate the destination buffer. This makes using it the way it is now in the DASH demuxer dangerous. So use av_strlcpy instead. Also don't write anything if there is no id: The buffer has already been zeroed initially. The DASH testset from the Universität Klagenfurt contains samples with ids that are too long. E.g. http://ftp.itec.aau.at/datasets/DASHDataset2014/TearsOfSteel/1sec/TearsOfSteel_1s_simple_2014_05_09.mpd Signed-off-by: Andreas Rheinhardt --- libavformat/dashdec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index b82805c9ce..3a12aefa68 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -1042,7 +1042,8 @@ static int parse_manifest_representation(AVFormatContext *s, const char *url, if (rep->fragment_duration > 0 && !rep->fragment_timescale) rep->fragment_timescale = 1; rep->bandwidth = rep_bandwidth_val ? atoi(rep_bandwidth_val) : 0; - strncpy(rep->id, rep_id_val ? rep_id_val : "", sizeof(rep->id)); + if (rep_id_val) + av_strlcpy(rep->id, rep_id_val, sizeof(rep->id)); rep->framerate = av_make_q(0, 0); if (type == AVMEDIA_TYPE_VIDEO) { char *rep_framerate_val = xmlGetProp(representation_node, "frameRate");