From patchwork Sat Apr 21 21:03:46 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: 8551 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp2073235jad; Sat, 21 Apr 2018 14:03:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx49gszr0M94HykBVqHq3HkzCmSDMBBthPAouHfAQLz/0HMBtEPB13EvbKK09tolpJqiKbZIC X-Received: by 2002:adf:8248:: with SMTP id 66-v6mr12124847wrb.127.1524344638029; Sat, 21 Apr 2018 14:03:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524344637; cv=none; d=google.com; s=arc-20160816; b=gHjx5N9eiXfX/olT/99XpjfoigunQ4LcwZ+zwTzHugAK2PXHdEQ2fiOa+skwDSsInZ uOWRj4TveYLQiL9HxKmZX0OLadBAjn9mprJMUtaS63UGE/vKgINB2AFEopdiB5d6YEkg gGd5IOAAoRQ/+MI+dwlDK1KLpDd6DAP2AZvTEkvmQQ24h7HZ27MBx2YfpgSmNd7e7qMe tg8089zE+6T1qBbiRtumj0sxh8UaQFR9FyAXHQWenhO9s+FPaVu+Ukwh4ggz8m85v7fT 5PXKwy7fmVgZXupPLOHyWxGGUyrkAqsxnwGpZPt9+UaEh87I62GFol9Ui2BEPbqvMNoF sazg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:delivered-to:arc-authentication-results; bh=ZbgL9hWz0RMWETY2sBazjdqUE1IAJodZv4P3GLvmjzw=; b=Sssxr5nN3vRKOmuGp0mZz7AQvoK1yPMIcx/ZrWLyywsnra1jJgAmqTDKDBuW1evdUh EkjnD/F+dPuNU2jfho/EUbnJe6EwNssNw1JgxCt/QWjwsCyF5n6FdcW9EKliSsdZ6XHT mY0gVTmWEIC9SdDkrzyfyc5FItFWbstKpOzSpYX0qyWXSrkC0VX9TVPCMjfRRtC/jxCS eshXCAUNfr84Vc/X+N1KWAeh10Qc1JqsjxGR7AkJw59jcUikWpoLQG9v2MdR7eyEJ8nN Je1/Y5YNId1Ebe2q1x09m5qi3HgnyOxH7rjv2gTR+sgRAT/GxNd+JOWVE3hQ6MFrMrLH +Flg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=LMVA4Dyb; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q48-v6si6269101wrb.209.2018.04.21.14.03.57; Sat, 21 Apr 2018 14:03:57 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=LMVA4Dyb; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9778F68A16E; Sun, 22 Apr 2018 00:03:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io0-f180.google.com (mail-io0-f180.google.com [209.85.223.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4BDAB68A043 for ; Sun, 22 Apr 2018 00:03:20 +0300 (EEST) Received: by mail-io0-f180.google.com with SMTP id d26-v6so14220215ioc.2 for ; Sat, 21 Apr 2018 14:03:48 -0700 (PDT) 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=xGc9Kfag9zTWudITlGzRWVfnO9S3JD7u9q4mi/0a/es=; b=LMVA4DybQ/f7LFom5gtubUo8kdYAl/7Kl+kqaCJ6lCaQy6oB9oO7gber3O80o3yokr dgz+1aWHZlXJXrMyq+i8r2mlqIcZcNpyI1Qe/5sgL6x5paZ320OSzbL6i91iSCcv98uT ILmR58uvmoRbTzFlKSuN1pp8lsDHM3UJV4b/atmVOL+9c1sGsQ6ULrt7M4WxubExTTwT +rgd7ISpicVhFWL6L8rF/1yrJFiQ5WkS3NOPZcBReZuJFGQkBiQpAjqTk7LOQFCbilvk neSo/RQuHpbqG9BfXNZ9rJG6CirWK2eR+zpBz0tPy4Sr9sqnODMphP8kUITKVhbTVB8L TQYA== 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=xGc9Kfag9zTWudITlGzRWVfnO9S3JD7u9q4mi/0a/es=; b=OCn9Z+hTN2MFxAiKwEfONmo8eTbpbLI1uMxiqPJehQUssPn7Ama9/MusAq6zy6VKkq xtChRYzrTd+C+CvN1zuL5HZ0HPG+wHOiKz5hX/CC5dx4c2wo+jn3HpJfn7I0fbFlfcB2 JM6xjNEdoWmo9F1o6yWBdGRWuvJ8VcvB4TWmdyrz8i6SXbiVUPXKHCcmeZvoaHGQ6OHx 0WAO+0FmwZYOsaghHYa+iycu6o27xywmFe246UMCueKBpFlCyQoEjUwoKjlMSyWaSS2i hjZeIMGRSrqbHQEyKZcq5PSfsCXtOAtIuK6vZAkOR3xyUs3dtZsEesL8WNcflQ/75fw9 UTWQ== X-Gm-Message-State: ALQs6tADz4afrgj3rI/uj5121s6/1PFBfLVnY9OsXvMCky0bXhOUwhNv nVjiN+fv1K9KzihueNtrrFFN3jr3yeH16oCvRHw= X-Received: by 2002:a6b:974d:: with SMTP id z74-v6mr15478800iod.12.1524344627649; Sat, 21 Apr 2018 14:03:47 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a02:9041:0:0:0:0:0 with HTTP; Sat, 21 Apr 2018 14:03:46 -0700 (PDT) In-Reply-To: <20180418220036.095014bc@debian> References: <20180418220036.095014bc@debian> From: Carl Eugen Hoyos Date: Sat, 21 Apr 2018 23:03:46 +0200 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH]lavf/dashdec: Do not use memcpy() to copy a struct 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-04-18 22:00 GMT+02:00, wm4 : > On Wed, 18 Apr 2018 21:52:45 +0200 > Carl Eugen Hoyos wrote: > >> From cf7d2aefc1a3b3a2e9f578ede43906ed6ee96bfd Mon Sep 17 00:00:00 2001 >> From: Carl Eugen Hoyos >> Date: Wed, 18 Apr 2018 19:42:57 +0200 >> Subject: [PATCH] lavf/dashdec: Do not use memcpy() to copy a struct. >> >> Fixes a warning: >> libavformat/dashdec.c:1900:65: warning: argument to 'sizeof' in 'memcpy' >> call is the same pointer type 'struct fragment *' as the destination; >> expected 'struct fragment' or an explicit length >> --- >> libavformat/dashdec.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c >> index 6304ad9..917fb54 100644 >> --- a/libavformat/dashdec.c >> +++ b/libavformat/dashdec.c >> @@ -1897,7 +1897,7 @@ static int init_section_compare_audio(DASHContext >> *c) >> >> static void copy_init_section(struct representation *rep_dest, struct >> representation *rep_src) >> { >> - memcpy(rep_dest->init_section, rep_src->init_section, >> sizeof(rep_src->init_section)); >> + *rep_dest->init_section = *rep_src->init_section; >> rep_dest->init_sec_buf = av_mallocz(rep_src->init_sec_buf_size); >> memcpy(rep_dest->init_sec_buf, rep_src->init_sec_buf, >> rep_src->init_sec_data_len); >> rep_dest->init_sec_buf_size = rep_src->init_sec_buf_size; > > Probably not complete, because it doesn't copy the url field. I don't disagree but failed to test my attached approach. Patch applied, Carl Eugen diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index 6304ad9..c1b3131 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -1895,14 +1895,27 @@ static int init_section_compare_audio(DASHContext *c) return 1; } -static void copy_init_section(struct representation *rep_dest, struct representation *rep_src) +static int copy_init_section(struct representation *rep_dest, struct representation *rep_src) { + void *buf, *buf2; + buf = av_mallocz(rep_src->init_section->size); + if (!buf) + return AVERROR(ENOMEM); + buf2 = av_mallocz(rep_src->init_sec_buf_size); + if (!buf2) { + av_free(buf); + return AVERROR(ENOMEM); + } *rep_dest->init_section = *rep_src->init_section; + rep_dest->init_section->url = buf; + memcpy(rep_dest->init_section->url, rep_src->init_section->url, rep_src->init_section->size); - rep_dest->init_sec_buf = av_mallocz(rep_src->init_sec_buf_size); + rep_dest->init_sec_buf = buf2; memcpy(rep_dest->init_sec_buf, rep_src->init_sec_buf, rep_src->init_sec_data_len); rep_dest->init_sec_buf_size = rep_src->init_sec_buf_size; rep_dest->init_sec_data_len = rep_src->init_sec_data_len; rep_dest->cur_timestamp = rep_src->cur_timestamp; + + return 0; } @@ -1942,7 +1955,9 @@ static int dash_read_header(AVFormatContext *s) for (i = 0; i < c->n_videos; i++) { struct representation *cur_video = c->videos[i]; if (i > 0 && c->is_init_section_common_video) { - copy_init_section(cur_video,c->videos[0]); + ret = copy_init_section(cur_video,c->videos[0]); + if (ret < 0) + return ret; } ret = open_demux_for_component(s, cur_video); @@ -1959,7 +1974,9 @@ static int dash_read_header(AVFormatContext *s) for (i = 0; i < c->n_audios; i++) { struct representation *cur_audio = c->audios[i]; if (i > 0 && c->is_init_section_common_audio) { - copy_init_section(cur_audio,c->audios[0]); + ret = copy_init_section(cur_audio,c->audios[0]); + if (ret < 0) + return ret; } ret = open_demux_for_component(s, cur_audio);