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 98AB547843 for ; Thu, 26 Oct 2023 11:08:59 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6DA5968CA99; Thu, 26 Oct 2023 14:08:57 +0300 (EEST) Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9ABC668C9B0 for ; Thu, 26 Oct 2023 14:08:51 +0300 (EEST) Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-41cbcb392e5so1182261cf.0 for ; Thu, 26 Oct 2023 04:08:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698318529; x=1698923329; darn=ffmpeg.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=MZRo/ODwZqTJdzU9HwjRHuudTmtUkhqTumi0JtlwitU=; b=JRaQal/v63rF/OL1dGXC29+zLE8YBjsjkZpubhhvqVraZObC87YS/ht58XkFQRjcGM 5wZKdVAF4PWm2fv1Qa+vZe7zuw58Kw9p0x1SgI5BgxZrx50uyOKIt6PWIel7OZ0j/+X8 oa5fMFhYVY9Do96XrFahW9SMeQtzO0tff8eSrX/zL0RtcLgHAiUxf1tJvRtLqtC4Zr4o PHw4VRsyDRzQCxYNZB1oBgZYsl5l/KArOBxoiCOG9pMeI50+hkS9QocaH2PnfkwP08PJ CsFQD8zNzKafMbuxnALNh+kXAeirX/Gs8xfg4qLFlB+mKEDVMJy7svO+SV/IFMydKlit oOCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698318529; x=1698923329; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MZRo/ODwZqTJdzU9HwjRHuudTmtUkhqTumi0JtlwitU=; b=TAlqtLZhlHG6KFZojdLKL3eoQrETEB1qkYnUUZbzUWR7w3C9PsYGc+skrR3cpmUcvg +8cvVUlK8iFwzGPHRJF+3SKpOFeM7KCfR72V7D/Yf8oAGOEa/hj3PTSU1YOl4XtE22Jc kYldN8AIJOLdH31/GlwxS7m1w0IlE4aJl8gmeMYLR9VvBxotcxebS10AWzzz0+QJWaDr WAplLSgEfgeX9NLnup7bfrb3vUALr5lzyWUn93HngOWYDpvtfQDMJ05ubxDnFu661OfS mpKUCD9atyESWEuTWdnpm38IWbPUdEFw27ohzp7HgAGuqUNdCZC3zSZqyaR9RdpOBHPC ePBw== X-Gm-Message-State: AOJu0Yz3UItGURttoKqtNZp25v3R1DFoiovdWLpO+hCFMhGfvsUPhQ+a QntUy90z3noahQaIyGBKKR/LX8m5kTfueQ== X-Google-Smtp-Source: AGHT+IEbmMzhhxgAHrUYQHVPOC+ovHrlQfUY18FZtEY6RtcmJc8gIcDNuY8QaSNJAYWcXWMwKun+wQ== X-Received: by 2002:a05:620a:4805:b0:774:17d6:31dc with SMTP id eb5-20020a05620a480500b0077417d631dcmr18185633qkb.4.1698318528827; Thu, 26 Oct 2023 04:08:48 -0700 (PDT) Received: from [192.168.1.35] (c-68-56-149-176.hsd1.mi.comcast.net. [68.56.149.176]) by smtp.gmail.com with ESMTPSA id d21-20020a05620a141500b0076f12fcb0easm4919138qkj.2.2023.10.26.04.08.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Oct 2023 04:08:48 -0700 (PDT) Message-ID: <0b8dd24b-ee83-4832-a830-9b33bfad62c8@gmail.com> Date: Thu, 26 Oct 2023 07:08:47 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: ffmpeg-devel@ffmpeg.org References: <20231026031427.150182-1-leo.izen@gmail.com> Content-Language: en-US-large From: Leo Izen In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH] avformat/hls: use av_strlcopy instead of strncpy 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 10/26/23 06:54, Andreas Rheinhardt wrote: > Leo Izen: >> Avoids a -Wstringop-truncation warning by using av_strlcopy instead of >> strncpy. >> >> Signed-off-by: Leo Izen >> --- >> libavformat/hls.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/libavformat/hls.c b/libavformat/hls.c >> index f5f549b24d..076f92ecfb 100644 >> --- a/libavformat/hls.c >> +++ b/libavformat/hls.c >> @@ -543,7 +543,7 @@ static struct rendition *new_rendition(HLSContext *c, struct rendition_info *inf >> int langlen = strlen(rend->language); >> if (langlen < sizeof(rend->language) - 3) { >> rend->language[langlen] = ','; >> - strncpy(rend->language + langlen + 1, info->assoc_language, >> + av_strlcpy(rend->language + langlen + 1, info->assoc_language, >> sizeof(rend->language) - langlen - 2); >> } >> } > > Doesn't this just silence the warning instead of fixing the potential > truncation? > > - Andreas > The semantics of strlcpy and strncpy are slightly different. strlcopy *always* nul-terminates the destination string. strncpy zeroes the buffer and then runs memcpy, so if it would overflow the buffer the string ends up without a nul-terminator. The warning triggers because the compiler thinks that case can occur. - Leo Izen _______________________________________________ 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".