From patchwork Fri May 7 11:00:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 27648 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp417341iof; Fri, 7 May 2021 04:00:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxU90s3jhVpC3k/TKpJGz4flzgiWcvCQiDaqphRiq9+0cmKfy+Lhz0VmKXNgNUlPs5RJ8V3 X-Received: by 2002:aa7:c349:: with SMTP id j9mr10503850edr.230.1620385238041; Fri, 07 May 2021 04:00:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620385238; cv=none; d=google.com; s=arc-20160816; b=BObIRN2qXDlrFHp7Jnkz6H/2gJZUFO0knleXPK3yQpHgAFlVe/5pqMjYFa9bKyTC/5 HGHXX2mLvG+RLmWdkCQSp3CYubqoqXIuWp34x1Oxae3fwXIcQaePjSwzgDkLLpxlk0MF znJtyuqKNDMnL/sPSM0fQzz01ESkDNTBPIZ69VuYtViWfK/8BPHzjI7+FjOB/y3orOcp VAvU9HH5F/JLlB2pdS+juwCnLiWX2BcsL7bBaB2UPEd8R19W6BC7mnnJJr34SZgbrf92 vAoHJksYqn1XElePPev4/z1OY6eI2wJi8bAhBzO3unEPlfyHoWJTBuyy0meT6skbwsqb C5/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=x8L6/PfeJOfuSBYxuRIO58Z7c4OWIIgOoiOEj3w9Mzc=; b=I5s7fetuUXqffINaFh+EEmBk4vrDs1/d8KXGHOnlZ+2QCNpPHb3tlnXz8b0736tiYV uYgM8bk/VJhFH+sMw2a9dAxBqNzEkVqvyin/8MzEcBus1vwJm1NPLAqzKBJUnGkworWK VNKuCSAhQuHnnuxXlOsWkp+6frORkZlrmIKkus+DeejOntMbCgzY+1NEtfHsi6XhjZrV svMmRzGEEl09bFLxqPn/Oqpv5USMb/TudcAYqcEC/PPJXPI8PCMl032sgQmpvGUI5HkQ X1EFN/UwEYhFDbglSLHsxE1dhFFy81CGOHjLbrB3tsWqJN+g6PoKq5lc6ZbrAsqMzMmv 5Lgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=jdIWhFcV; 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 ds10si6353971ejc.415.2021.05.07.04.00.37; Fri, 07 May 2021 04:00:38 -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=jdIWhFcV; 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 4CCA5680372; Fri, 7 May 2021 14:00:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D4AC368033C for ; Fri, 7 May 2021 14:00:25 +0300 (EEST) Received: by mail-pf1-f176.google.com with SMTP id i190so7295540pfc.12 for ; Fri, 07 May 2021 04:00:25 -0700 (PDT) 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; bh=rLjyxxKlCtWHcRkeLAylknbFYcgOmbvB8EGlSPBUDEo=; b=jdIWhFcVRyG42P7ZU076E3WDP+S2ESmO3ywYI3EE56CpNzZPeSNVYajDUgWsXaBIIL gpzAy/smiV+dvc5STce/YGfPtpJVCOLfbSRQ410KfRK5j2vEIJvG1Pm42lhKamfn6SbU CQV/IYbHHwKBnlQX5wX6Akln0QHAqwxmIsTop9B3YDOS/5YgpKdPncMXlh0puZYUJMi0 KLyCXLR9Db+GKypaGa+dqeBM+UNBHaSF8WtvkuuFyUJc4CTtwLSXWA6WhQjK5xS1zVop usU+qsauL2LfHXfb426H0zHAFpr/t38841Fw0m9Wvn4k8fcjS+9nmY67AFdJESfdqOb/ aDQw== 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; bh=rLjyxxKlCtWHcRkeLAylknbFYcgOmbvB8EGlSPBUDEo=; b=YztdfT8IDhRndGkJ0gr5vZuHashEkxUYv00uAjvd/WX7e+/aOmmSaQSDy3aubLNKQE BNwI8elqF+dAPJ6ODNlVjdkI8IQPhcYOS5NxUOyehLkavJPZgYUXA3vdVAhjUh2vC6vI czRvxZ0CEs0ARfOB5SV6Vyiey6Y71KIRRoNgmYUh6Oc22YIsjxHVoPwtwQpnSP1+5wi7 HmEdhNSt6csKe48krZMJ/JjQZiFnofUL/uUehj2nuBXGDc59ZaAImYpOMSi0Fdot6S8m Sbx8tL7jVqlyj9Iwdbxpa043MakQt7MENEHV7Gf/X9VGKKPjzdpFYJ1ZZoKfYPLze7pM Pnhg== X-Gm-Message-State: AOAM533SagjsMNNBU+mDo1Hw/GXP43KQ4jf33sONWhFojISbggpCuocE rgpHG3WiQyEDuIHaNL8/7BTBCd612Ws= X-Received: by 2002:aa7:8e85:0:b029:28f:2620:957e with SMTP id a5-20020aa78e850000b029028f2620957emr9769165pfr.40.1620385223719; Fri, 07 May 2021 04:00:23 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id k38sm4462629pgi.73.2021.05.07.04.00.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 May 2021 04:00:23 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Fri, 7 May 2021 19:00:15 +0800 Message-Id: <1620385216-31085-1-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1620350584-21215-1-git-send-email-lance.lmwang@gmail.com> References: <1620350584-21215-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v2 1/2] avfilter/dnn/dnn_backend_tf: fix cross library usage 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 Cc: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: /UlVWAkHBvWc From: Limin Wang duplicate ff_hex_to_data() function from avformat and rename it to hex_to_data() as static function. Signed-off-by: Limin Wang --- libavfilter/dnn/dnn_backend_tf.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c index 03fe310..eb11cb5 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -28,8 +28,8 @@ #include "dnn_backend_native_layer_conv2d.h" #include "dnn_backend_native_layer_depth2space.h" #include "libavformat/avio.h" -#include "libavformat/internal.h" #include "libavutil/avassert.h" +#include "libavutil/avstring.h" #include "../internal.h" #include "dnn_backend_native_layer_pad.h" #include "dnn_backend_native_layer_maximum.h" @@ -195,6 +195,38 @@ static DNNReturnType get_output_tf(void *model, const char *input_name, int inpu return ret; } +#define SPACE_CHARS " \t\r\n" +static int hex_to_data(uint8_t *data, int data_size, const char *p) +{ + int c, len, v; + + len = 0; + v = 1; + for (;;) { + p += strspn(p, SPACE_CHARS); + if (*p == '\0') + break; + c = av_toupper((unsigned char) *p++); + if (c >= '0' && c <= '9') + c = c - '0'; + else if (c >= 'A' && c <= 'F') + c = c - 'A' + 10; + else + break; + v = (v << 4) | c; + if (v & 0x100) { + if (data) { + if (len >= data_size) + return -1; + data[len] = v; + } + len++; + v = 1; + } + } + return len; +} + static DNNReturnType load_tf_model(TFModel *tf_model, const char *model_filename) { TFContext *ctx = &tf_model->ctx; @@ -219,14 +251,14 @@ static DNNReturnType load_tf_model(TFModel *tf_model, const char *model_filename return DNN_ERROR; } config = tf_model->ctx.options.sess_config + 2; - sess_config_length = ff_hex_to_data(NULL, config); + sess_config_length = hex_to_data(NULL, 0, config); sess_config = av_mallocz(sess_config_length + AV_INPUT_BUFFER_PADDING_SIZE); if (!sess_config) { av_log(ctx, AV_LOG_ERROR, "failed to allocate memory\n"); return DNN_ERROR; } - ff_hex_to_data(sess_config, config); + hex_to_data(sess_config, sess_config_length, config); } graph_def = read_graph(model_filename); From patchwork Fri May 7 11:00:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 27649 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp417539iof; Fri, 7 May 2021 04:00:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaloWChEy70bAspIEkvPZ/XTrDqshUl5B/NDEObIcugvhEWWuZvz8KrDq/AnJxiZGeV7Wk X-Received: by 2002:aa7:c918:: with SMTP id b24mr10594269edt.58.1620385250456; Fri, 07 May 2021 04:00:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620385250; cv=none; d=google.com; s=arc-20160816; b=QdaFNfH06kORsZIjPpBAS+2jUSv5xrXSxzoBEFp5pAgmKxxsmZUWx9euT3eBvJM3WC hHLs6UJZP0LMWBGdkmeK2N7b1tYSonI4C/N76kPj5vRp+/k+Cx5B8NNzIwMF/8v1Hyhs pgvI5cpcahSexRlxvmTb2/edmluX5aHxcFSSuPWpi2yx1p3jkmR+ggTD62l5GkelLTsx Kp9qLgkHsjNPjOxHHR01z1jOECN62/yzdokgiq85UlEuHIRmh6D8J5X7U04ST7h7fX6l FjHwtgaFmYsgJpX0uNjgBi52Iy+gZP4Q+B019UA0uj2D1eJXmw6+70bS1yv9GB0p9odn qNkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=IHj57ZkbFxE2/oDM55yShehjZPU+eUyz/foJ9LnMOLU=; b=q2LbfCFOI0IZWUI/lOhxoqwGgazxdubHxSf1nDMIWzwY7k/4mVIvXKPPXahf2BtAUU /forg2DI2lKhEdhZ3D058LPHhMlKQYgLzASZPhfunNd4Rm/d6rWTJTV5Y8g9E26L1DgQ 30p/MkX2i/t5krPI6+2IsM3YJwbOf/MVO/4tn9VovnlWbPQPlg88cWX2MSgSGoE90ijC P72tntaPNrys9ifT5NTbjS8h3WxuGa7bR9j/QVZP+EE4dvekIVPy7P3C4sIIxcxI3J6C iEj6WoBesbpfMWjR/JyyyGTPsgpUzKiYfmfQmAzHQcvRHaGWPzPZPmRV+KpXafs6cpNv LePQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=OgL1vb43; 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 lt7si4799296ejb.446.2021.05.07.04.00.49; Fri, 07 May 2021 04:00:49 -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=OgL1vb43; 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 58AD46804D6; Fri, 7 May 2021 14:00:34 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0627E6804D6 for ; Fri, 7 May 2021 14:00:27 +0300 (EEST) Received: by mail-pj1-f52.google.com with SMTP id t2-20020a17090a0242b0290155433387beso4427758pje.1 for ; Fri, 07 May 2021 04:00:26 -0700 (PDT) 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; bh=srbiHhies3YD8oF6IC1v7txGYhxTNEntQmBvFaXpaTU=; b=OgL1vb43Zk+t10b2MErY+q3hXX5ul8uoWXp+OkvP7a8UPBY52pQqaVFv4MTfLAH3hE 7TEm5d0+ee5BtZZn2FNwmmPFqXOirsicBmcFcq+6M35v5EOqdWhyMc435xLa/Z2hTmCE /k45EPspPmqoBvm/Hb+OXlLK2T9IyOTjBXFPKWJniVeF+s1JLYvdpx4lOYaBwBwc+IDf Wzoj6GEWiYpEwHSqEpt2UgXS5wXhUhh4RKiMTbTvjy+jfUBGjn6kwPBtX5LSoufNI5Zv vmmQp18aFEzzXFG3Az22KM56DVcbdU3GxiuCWmWoF42nqNMNHR+fbzUGfiKOlsQhqYYr Jrrg== 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; bh=srbiHhies3YD8oF6IC1v7txGYhxTNEntQmBvFaXpaTU=; b=tb55RNw3qvrZ72Ag2x7ouY0trPbsZpq6ZKRlStl0MmazfkZjsPcNP+4owMb5U7tbE/ upzqewz80m4K6CXwtFOr/YmIOP1w/PXMSdTs3cSeFTnmExqWeOtW6xfUMpPEvA2WkPXl kCzkheg+QwnXnrWhMv0BItEP0RcY7FB+M1iiSdT3ihT2ixa0zltfgeMsBpFBtLVJEBA5 8+KTSl2hk7RbRZay8Kouln6eqQ9Dqs5SeHLmS/nBjF5Dy/pw9fFc/H+hVIsdQosfVENW NHyDX8hoRVeqWwg3jxTzUKuMI/xBkAjZ9LD94GNMPvIifsrTFdjI2XRHsNYmacYEypHa nLFA== X-Gm-Message-State: AOAM5307VHwPBh7y+8KWw/N8u826gaSAdAdqEul432OVktuCrdjKzIsX KbnpLHErbBLQUzLViW2gvotSRziunyM= X-Received: by 2002:a17:90a:2844:: with SMTP id p4mr23676995pjf.89.1620385224965; Fri, 07 May 2021 04:00:24 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id k38sm4462629pgi.73.2021.05.07.04.00.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 May 2021 04:00:24 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Fri, 7 May 2021 19:00:16 +0800 Message-Id: <1620385216-31085-2-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1620385216-31085-1-git-send-email-lance.lmwang@gmail.com> References: <1620350584-21215-1-git-send-email-lance.lmwang@gmail.com> <1620385216-31085-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v2 2/2] avformat: add data_size for ff_hex_to_data() 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 Cc: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: OLUiFfG7yECb From: Limin Wang This prevents OOM in case of data buffer size is insufficient. Signed-off-by: Limin Wang --- libavformat/hls.c | 2 +- libavformat/internal.h | 6 ++++-- libavformat/rtpdec_latm.c | 4 ++-- libavformat/rtpdec_mpeg4.c | 4 ++-- libavformat/utils.c | 7 +++++-- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index 584f658..c7f9f06 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -800,7 +800,7 @@ static int parse_playlist(HLSContext *c, const char *url, if (!strcmp(info.method, "SAMPLE-AES")) key_type = KEY_SAMPLE_AES; if (!strncmp(info.iv, "0x", 2) || !strncmp(info.iv, "0X", 2)) { - ff_hex_to_data(iv, info.iv + 2); + ff_hex_to_data(iv, sizeof(iv), info.iv + 2); has_iv = 1; } av_strlcpy(key, info.uri, sizeof(key)); diff --git a/libavformat/internal.h b/libavformat/internal.h index 7d0eab4..e0e625f 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -397,10 +397,12 @@ char *ff_data_to_hex(char *buf, const uint8_t *src, int size, int lowercase); * digits is ignored. * * @param data if non-null, the parsed data is written to this pointer + * @param data_size the data buffer size * @param p the string to parse - * @return the number of bytes written (or to be written, if data is null) + * @return the number of bytes written (or to be written, if data is null), + * or a negative value in case data buffer size is insufficient. */ -int ff_hex_to_data(uint8_t *data, const char *p); +int ff_hex_to_data(uint8_t *data, int data_size, const char *p); /** * Add packet to an AVFormatContext's packet_buffer list, determining its diff --git a/libavformat/rtpdec_latm.c b/libavformat/rtpdec_latm.c index 104a00a..c348cc8 100644 --- a/libavformat/rtpdec_latm.c +++ b/libavformat/rtpdec_latm.c @@ -91,7 +91,7 @@ static int latm_parse_packet(AVFormatContext *ctx, PayloadContext *data, static int parse_fmtp_config(AVStream *st, const char *value) { - int len = ff_hex_to_data(NULL, value), i, ret = 0; + int len = ff_hex_to_data(NULL, 0, value), i, ret = 0; GetBitContext gb; uint8_t *config; int audio_mux_version, same_time_framing, num_programs, num_layers; @@ -100,7 +100,7 @@ static int parse_fmtp_config(AVStream *st, const char *value) config = av_mallocz(len + AV_INPUT_BUFFER_PADDING_SIZE); if (!config) return AVERROR(ENOMEM); - ff_hex_to_data(config, value); + ff_hex_to_data(config, len, value); init_get_bits(&gb, config, len*8); audio_mux_version = get_bits(&gb, 1); same_time_framing = get_bits(&gb, 1); diff --git a/libavformat/rtpdec_mpeg4.c b/libavformat/rtpdec_mpeg4.c index 34c7950..540192c 100644 --- a/libavformat/rtpdec_mpeg4.c +++ b/libavformat/rtpdec_mpeg4.c @@ -112,11 +112,11 @@ static void close_context(PayloadContext *data) static int parse_fmtp_config(AVCodecParameters *par, const char *value) { /* decode the hexa encoded parameter */ - int len = ff_hex_to_data(NULL, value), ret; + int len = ff_hex_to_data(NULL, 0, value), ret; if ((ret = ff_alloc_extradata(par, len)) < 0) return ret; - ff_hex_to_data(par->extradata, value); + ff_hex_to_data(par->extradata, par->extradata_size, value); return 0; } diff --git a/libavformat/utils.c b/libavformat/utils.c index 6c8b974..7085c28 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -4762,7 +4762,7 @@ char *ff_data_to_hex(char *buff, const uint8_t *src, int s, int lowercase) return buff; } -int ff_hex_to_data(uint8_t *data, const char *p) +int ff_hex_to_data(uint8_t *data, int data_size, const char *p) { int c, len, v; @@ -4781,8 +4781,11 @@ int ff_hex_to_data(uint8_t *data, const char *p) break; v = (v << 4) | c; if (v & 0x100) { - if (data) + if (data) { + if (len >= data_size) + return -1; data[len] = v; + } len++; v = 1; }