From patchwork Tue Mar 2 09:16:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26058 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 7069344B121 for ; Tue, 2 Mar 2021 11:17:52 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 51B4468AB8E; Tue, 2 Mar 2021 11:17:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 432F068AB48 for ; Tue, 2 Mar 2021 11:17:45 +0200 (EET) Received: by mail-ed1-f51.google.com with SMTP id c6so24304159ede.0 for ; Tue, 02 Mar 2021 01:17:45 -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:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=HJcS2Z6Yrrobtxip7RqkWlfs17BcqGkh9Nl56Lb5ILY=; b=OlD/xrvACnZBSDMyf/PkuI5OLCakK5GNIksXj0JSNnBEuJMCRLCMJXbWg39KWHkGYb DtTnwG4uhAIvgIqL2UgKDIAILAbQETbTvdcZE2fVwf+FbWu9o4np5zB+Pe3OFjZBphHZ J6yx7fhuJJU4PL5LrL8AabKKNw99WRv18XotztEU6jfAg1Dc06XFnrXGT9l9iROpQs4r 4F8BUHQmwG1KuY+45bOVCeO/OliYuinrHoqpA+u+BO+haMZl5nt5dahem5P7C2QEzuNG nzEgfgnwN6hngBX2G1/A4rYIwYIB9aw0ilr0/gWTgzZLBj6wqN526Pa9bteYC5JBvZ/q g1cA== 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:reply-to:mime-version:content-transfer-encoding; bh=HJcS2Z6Yrrobtxip7RqkWlfs17BcqGkh9Nl56Lb5ILY=; b=VLNpPkINUEXfodwkwJ4VaP0YUY4Iqh2VQWNfcsR/zZGyT9nrGT5RYhtaWcv2nhWKao epTTkloXGUGXEgqrmiWdG7JPoOU/6qgiepUcq+czg3orA8sVY0GjSHDJtPLc2dfG4jGP zJButEvt7q4WMYujWJaFO9HB3GbWip0U+SJR/+fg0+NtN+5VHptSFthG5+mKA4X/7+kB acdlR2iHuwEFMpOvYsAsp/cFTfM0TsBspFQlNWikUldzT+eShvIgjw/XiWlrZTGkkv/R 5zDwOGn+ZCJmjdDucKzGoZcanVSrmdL1sKrh4bG1Jo9phvBP8Zh/NhmFXnkLokB+yNkr ILMg== X-Gm-Message-State: AOAM530s8lQm+JS46KF7xjWkxssM/2nqZQNf6GXgM9y83E6VxRdlGW4J BpM4K1hYhcS57V9FoS5VNPj/4oTijpg= X-Google-Smtp-Source: ABdhPJwze0uxAs4qXgBCGjocUPLr3xI+ZFbRKxSEqwu9dLGGlJ4W3JaGxoTW5JxfRb0/1+WVA1yRDA== X-Received: by 2002:a05:6402:11c6:: with SMTP id j6mr20459716edw.138.1614676664606; Tue, 02 Mar 2021 01:17:44 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id v22sm166030ejj.103.2021.03.02.01.17.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 01:17:44 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 2 Mar 2021 10:16:57 +0100 Message-Id: <20210302091657.473380-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210302091657.473380-1-andreas.rheinhardt@gmail.com> References: <20210302091657.473380-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avformat/aadec: Replace strncpy by av_strlcpy 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" While this usage of strncpy is correct, said function nevertheless has the disadvantage of not automatically ensuring that the destination string is zero-terminated. So av_strlcpy should be preferred. This also removes a -Wstringop-truncation warning from GCC (it doesn't matter whether the buffer is truncated, as long as it can fit all the names of the supported codecs). Signed-off-by: Andreas Rheinhardt --- libavformat/aadec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/aadec.c b/libavformat/aadec.c index b1e93ea072..e88cdb89df 100644 --- a/libavformat/aadec.c +++ b/libavformat/aadec.c @@ -114,7 +114,7 @@ static int aa_read_header(AVFormatContext *s) avio_get_str(pb, nval, val, sizeof(val)); if (!strcmp(key, "codec")) { av_log(s, AV_LOG_DEBUG, "Codec is <%s>\n", val); - strncpy(codec_name, val, sizeof(codec_name) - 1); + av_strlcpy(codec_name, val, sizeof(codec_name)); } else if (!strcmp(key, "HeaderSeed")) { av_log(s, AV_LOG_DEBUG, "HeaderSeed is <%s>\n", val); header_seed = atoi(val);