From patchwork Mon Dec 10 00:57:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 11353 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 0645244EB51 for ; Mon, 10 Dec 2018 02:57:42 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 533B168AA6F; Mon, 10 Dec 2018 02:57:32 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f68.google.com (mail-io1-f68.google.com [209.85.166.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A0C1168AA46 for ; Mon, 10 Dec 2018 02:57:25 +0200 (EET) Received: by mail-io1-f68.google.com with SMTP id r9so7511162ioa.1 for ; Sun, 09 Dec 2018 16:57:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=QBXT3QyG5JEsMeJOP6U44mCEIUX1MkfnS2+qWHkDNI8=; b=sBpJJ4b6NhIGOaudfnYVMA5LXZFkb6z3/hoHQW7jhtJnF7OEO8cp5jseWp1GLujxM4 qcxAtIKEpWhpFCt8pNqw0QZZFTUe3yAsm+AS4ruPsPgWtStyitPTuUbhY3yFcl6JbMkw RoNxEpNmPBhYi+F6/MarwzFVN/+Ama/nHvHn9L4CMQ8UAqqb6/utJeVA4r8Vd00sqT5Z g89GaFt6y3EL1uzrDIr1+/4OC8wzt1l/zn7dZ65UEicXW/ONlhA5yot8Dmgd5/1A4ZVN 7JqUtrmWTvplRUckL9N2mQdznmvVlkdv7x3Csge9kG+NqeqsIbdZHwBIDtpV/hcDAH5o dtkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=QBXT3QyG5JEsMeJOP6U44mCEIUX1MkfnS2+qWHkDNI8=; b=Fox1c+lQbAEHfT6XUuRulXtQJhb8VZnC660DFrhowCk5d05grT6CYFqj+W2uwBzlxr jWaakzA3HrAgqHCUb9FjoC/FignCp3D0FENMqlgk6rJ2mfIWRiFhFExyD+b/DF1jXPNN xd3KhXxhB9dS1VabsahxIds9Ej3KrWqjPeE/MpjQaw4tserLr1ZUc1Xd4m1LYGmxLA3D x+BqgCZeQGwQHEHWwy1IDWU2hdvQhUBskmLd17t8j5MuYahX7xaR41atqhaR62E4GJIo 4O/Cz/hIkV72SpDwHY+w93uTbpyZtlanfo5N0nJR5nM7mfx2qQ7OdrInKEOcogIYurtS bHfQ== X-Gm-Message-State: AA+aEWZku1K5NJsADT9wMVisjIzc0rXceTPO5nqXaih3jn+LV09U7eNx gR3fxVlA5Flmhlr8q1WOh4gmbPPN79Ha8LxUO1b1mw== X-Google-Smtp-Source: AFSGD/WnAsdKEXfQJ1M82MBMQT4hwy4LJWGPlqd0M8ni6icxXHe1jIQLxs2ZhIaNuM+hdxEKjzpQM+Jok3Nw70uLgAQ= X-Received: by 2002:a5e:c70d:: with SMTP id f13mr8840065iop.55.1544403455157; Sun, 09 Dec 2018 16:57:35 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a02:5f11:0:0:0:0:0 with HTTP; Sun, 9 Dec 2018 16:57:34 -0800 (PST) In-Reply-To: <5efd99b6-66fa-6804-72aa-914a6fdb45e1@jkqxz.net> References: <5efd99b6-66fa-6804-72aa-914a6fdb45e1@jkqxz.net> From: Carl Eugen Hoyos Date: Mon, 10 Dec 2018 01:57:34 +0100 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH]lavf/matroskadec: Do not use strncat() to limit copying a one-char constant 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 2018-12-09 19:03 GMT+01:00, Mark Thompson : > On 06/12/2018 22:26, Carl Eugen Hoyos wrote: >> Hi! >> >> Attached patch silences a new gcc warning, alternative would be to >> disable the warning. >> >> Please comment, Carl Eugen >> >> >> From dd49cddc6fad136222d4a168301059d55fea4a4c Mon Sep 17 00:00:00 2001 >> From: Carl Eugen Hoyos >> Date: Thu, 6 Dec 2018 23:23:12 +0100 >> Subject: [PATCH] lavf/matroskadec: Do not use strncat() to limit copying a >> one-char constant. >> >> Silences a warning: >> libavformat/matroskadec.c: In function 'webm_dash_manifest_cues': >> libavformat/matroskadec.c:3947:13: warning: 'strncat' specified bound 1 >> equals source length [-Wstringop-overflow=] >> strncat(buf, ",", 1); >> ^~~~~~~~~~~~~~~~~~~~ >> --- >> libavformat/matroskadec.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c >> index 2daa1db..df820b4 100644 >> --- a/libavformat/matroskadec.c >> +++ b/libavformat/matroskadec.c >> @@ -3944,7 +3944,7 @@ static int webm_dash_manifest_cues(AVFormatContext >> *s, int64_t init_range) >> } >> end += ret; >> if (i != s->streams[0]->nb_index_entries - 1) { >> - strncat(buf, ",", 1); >> + strcat(buf, ","); >> end++; >> } >> } >> -- >> 1.7.10.4 >> > > LGTM. > > (Optional: perhaps nicer to remove that code fragment with the str(n?)cat > completely by including the comma in the snprintf above, as '"%s", i != > s->streams[0]->nb_index_entries - 1 ? "," : ""'?) New patch attached. Please review, Carl Eugen From 082bce9706a4c326187ae543d8b8aa93424c48b0 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Mon, 10 Dec 2018 01:55:15 +0100 Subject: [PATCH] lavf/matroskadec: Do not use strncat() to limit copying a one-char constant. Instead add the character to the snprintf above as suggested by Mark. Silences a warning: libavformat/matroskadec.c: In function 'webm_dash_manifest_cues': libavformat/matroskadec.c:3947:13: warning: 'strncat' specified bound 1 equals source length [-Wstringop-overflow=] strncat(buf, ",", 1); ^~~~~~~~~~~~~~~~~~~~ --- libavformat/matroskadec.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 2daa1db..4ad99db 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -3936,17 +3936,14 @@ static int webm_dash_manifest_cues(AVFormatContext *s, int64_t init_range) strcpy(buf, ""); for (i = 0; i < s->streams[0]->nb_index_entries; i++) { int ret = snprintf(buf + end, 20, - "%" PRId64, s->streams[0]->index_entries[i].timestamp); + "%" PRId64"%s", s->streams[0]->index_entries[i].timestamp, + i != s->streams[0]->nb_index_entries - 1 ? "," : ""); if (ret <= 0 || (ret == 20 && i == s->streams[0]->nb_index_entries - 1)) { av_log(s, AV_LOG_ERROR, "timestamp too long.\n"); av_free(buf); return AVERROR_INVALIDDATA; } end += ret; - if (i != s->streams[0]->nb_index_entries - 1) { - strncat(buf, ",", 1); - end++; - } } av_dict_set(&s->streams[0]->metadata, CUE_TIMESTAMPS, buf, 0); av_free(buf); -- 1.7.10.4