From: vectronic <hello.vectronic@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Cc: vectronic <hello.vectronic@gmail.com>
Subject: [FFmpeg-devel] [PATCH 1/1] fix: use declared size for attribute of type string to ensure full value used and prevent parse failure for string lengths longer than 256
Date: Thu, 12 May 2022 16:30:19 +0100
Message-ID: <20220512153019.66066-2-hello.vectronic@gmail.com> (raw)
In-Reply-To: <20220512153019.66066-1-hello.vectronic@gmail.com>
Signed-off-by: vectronic <hello.vectronic@gmail.com>
---
libavcodec/exr.c | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 8cd867a32f..bc2afcee53 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -1912,10 +1912,13 @@ static int decode_header(EXRContext *s, AVFrame *frame)
continue;
} else if ((var_size = check_header_variable(s, "writer",
"string", 1)) >= 0) {
- uint8_t key[256] = { 0 };
+ uint8_t *key = av_malloc(var_size);
- bytestream2_get_buffer(gb, key, FFMIN(sizeof(key) - 1, var_size));
- av_dict_set(&metadata, "writer", key, 0);
+ if (!key)
+ return AVERROR(ENOMEM);
+
+ bytestream2_get_buffer(gb, key, var_size);
+ av_dict_set(&metadata, "writer", key, AV_DICT_DONT_STRDUP_VAL);
continue;
} else if ((var_size = check_header_variable(s, "framesPerSecond",
@@ -1937,9 +1940,12 @@ static int decode_header(EXRContext *s, AVFrame *frame)
continue;
} else if ((var_size = check_header_variable(s, "type",
"string", 16)) >= 0) {
- uint8_t key[256] = { 0 };
+ uint8_t *key = av_malloc(var_size);
+
+ if (!key)
+ return AVERROR(ENOMEM);
- bytestream2_get_buffer(gb, key, FFMIN(sizeof(key) - 1, var_size));
+ bytestream2_get_buffer(gb, key, var_size);
if (strncmp("scanlineimage", key, var_size) &&
strncmp("tiledimage", key, var_size))
return AVERROR_PATCHWELCOME;
@@ -1970,7 +1976,6 @@ static int decode_header(EXRContext *s, AVFrame *frame)
{
uint8_t name[256] = { 0 };
uint8_t type[256] = { 0 };
- uint8_t value[256] = { 0 };
int i = 0, size;
while (bytestream2_get_bytes_left(gb) > 0 &&
@@ -1987,9 +1992,18 @@ static int decode_header(EXRContext *s, AVFrame *frame)
bytestream2_skip(gb, 1);
size = bytestream2_get_le32(gb);
- bytestream2_get_buffer(gb, value, FFMIN(sizeof(value) - 1, size));
- if (!strcmp(type, "string"))
- av_dict_set(&metadata, name, value, 0);
+ if (strcmp(type, "string") != 0) {
+ bytestream2_skip(gb, size);
+
+ continue;
+ }
+ uint8_t *value = av_malloc(size);
+
+ if (!value)
+ return AVERROR(ENOMEM);
+
+ bytestream2_get_buffer(gb, value, size);
+ av_dict_set(&metadata, name, value, AV_DICT_DONT_STRDUP_VAL);
}
}
--
2.32.0 (Apple Git-132)
_______________________________________________
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".
next prev parent reply other threads:[~2022-05-12 15:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-12 15:30 [FFmpeg-devel] [PATCH 0/1] avcodec/exr: variable string attribute length vectronic
2022-05-12 15:30 ` vectronic [this message]
2022-05-14 10:41 ` [FFmpeg-devel] [PATCH 1/1] fix: use declared size for attribute of type string to ensure full value used and prevent parse failure for string lengths longer than 256 Paul B Mahol
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220512153019.66066-2-hello.vectronic@gmail.com \
--to=hello.vectronic@gmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git