* [FFmpeg-devel] [PATCH] avcodec/exif: avoid printing errors for makernote non-IFD parsing (PR #20604)
@ 2025-09-25 0:43 Leo Izen via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: Leo Izen via ffmpeg-devel @ 2025-09-25 0:43 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Leo Izen
PR #20604 opened by Leo Izen (Traneptora)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20604
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20604.patch
When we parse a MakerNote, we first try to parse it as an IFD and if
that fails, we try to re-parse it as a binary blob. This is because
MakerNote is not well-documented in its nature.
However, if we fail to parse it the first time, we should not av_log
error messages about the parse failure, so instead we log these as
AV_LOG_DEBUG.
Signed-off-by: Leo Izen <leo.izen@gmail.com>
Reported-by: Ramiro Polla <ramiro.polla@gmail.com>
>From 5af5f6d7c3253bf51a70645872d1dcc8b5e87d72 Mon Sep 17 00:00:00 2001
From: Leo Izen <leo.izen@gmail.com>
Date: Wed, 24 Sep 2025 20:34:26 -0400
Subject: [PATCH] avcodec/exif: avoid printing errors for makernote non-IFD
parsing
When we parse a MakerNote, we first try to parse it as an IFD and if
that fails, we try to re-parse it as a binary blob. This is because
MakerNote is not well-documented in its nature.
However, if we fail to parse it the first time, we should not av_log
error messages about the parse failure, so instead we log these as
AV_LOG_DEBUG.
Signed-off-by: Leo Izen <leo.izen@gmail.com>
Reported-by: Ramiro Polla <ramiro.polla@gmail.com>
---
libavcodec/exif.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/libavcodec/exif.c b/libavcodec/exif.c
index e7aa9b8d8f..877dead0fb 100644
--- a/libavcodec/exif.c
+++ b/libavcodec/exif.c
@@ -453,7 +453,7 @@ static int exif_get_makernote_offset(GetByteContext *gb)
}
static int exif_parse_ifd_list(void *logctx, GetByteContext *gb, int le,
- int depth, AVExifMetadata *ifd);
+ int depth, AVExifMetadata *ifd, int makernote);
static int exif_decode_tag(void *logctx, GetByteContext *gb, int le,
int depth, AVExifEntry *entry)
@@ -504,7 +504,7 @@ static int exif_decode_tag(void *logctx, GetByteContext *gb, int le,
return AVERROR(ENOMEM);
bytestream2_get_buffer(gb, entry->ifd_lead, entry->ifd_offset);
}
- ret = exif_parse_ifd_list(logctx, gb, le, depth + 1, &entry->value.ifd);
+ ret = exif_parse_ifd_list(logctx, gb, le, depth + 1, &entry->value.ifd, entry->id == MAKERNOTE_TAG);
if (ret < 0 && entry->id == MAKERNOTE_TAG) {
/*
* we guessed that MakerNote was an IFD
@@ -532,7 +532,7 @@ end:
}
static int exif_parse_ifd_list(void *logctx, GetByteContext *gb, int le,
- int depth, AVExifMetadata *ifd)
+ int depth, AVExifMetadata *ifd, int makernote)
{
uint32_t entries;
size_t required_size;
@@ -541,18 +541,21 @@ static int exif_parse_ifd_list(void *logctx, GetByteContext *gb, int le,
av_log(logctx, AV_LOG_DEBUG, "parsing IFD list at offset: %d\n", bytestream2_tell(gb));
if (bytestream2_get_bytes_left(gb) < 2) {
- av_log(logctx, AV_LOG_ERROR, "not enough bytes remaining in EXIF buffer: 2 required\n");
+ av_log(logctx, makernote ? AV_LOG_DEBUG : AV_LOG_ERROR,
+ "not enough bytes remaining in EXIF buffer: 2 required\n");
return AVERROR_INVALIDDATA;
}
entries = ff_tget_short(gb, le);
if (bytestream2_get_bytes_left(gb) < entries * BASE_TAG_SIZE) {
- av_log(logctx, AV_LOG_ERROR, "not enough bytes remaining in EXIF buffer. entries: %" PRIu32 "\n", entries);
+ av_log(logctx, makernote ? AV_LOG_DEBUG : AV_LOG_ERROR,
+ "not enough bytes remaining in EXIF buffer. entries: %" PRIu32 "\n", entries);
return AVERROR_INVALIDDATA;
}
if (entries > 4096) {
/* that is a lot of entries, probably an error */
- av_log(logctx, AV_LOG_ERROR, "too many entries: %" PRIu32 "\n", entries);
+ av_log(logctx, makernote ? AV_LOG_DEBUG : AV_LOG_ERROR,
+ "too many entries: %" PRIu32 "\n", entries);
return AVERROR_INVALIDDATA;
}
@@ -811,7 +814,7 @@ int av_exif_parse_buffer(void *logctx, const uint8_t *buf, size_t size,
* parse IFD0 here. If the return value is positive that tells us
* there is subimage metadata, but we don't parse that IFD here
*/
- ret = exif_parse_ifd_list(logctx, &gbytes, le, 0, ifd);
+ ret = exif_parse_ifd_list(logctx, &gbytes, le, 0, ifd, 0);
if (ret < 0) {
av_exif_free(ifd);
av_log(logctx, AV_LOG_ERROR, "error decoding EXIF data: %s\n", av_err2str(ret));
@@ -924,7 +927,7 @@ int avpriv_exif_decode_ifd(void *logctx, const uint8_t *buf, int size,
GetByteContext gb;
int ret;
bytestream2_init(&gb, buf, size);
- ret = exif_parse_ifd_list(logctx, &gb, le, depth, &ifd);
+ ret = exif_parse_ifd_list(logctx, &gb, le, depth, &ifd, 0);
if (ret < 0)
return ret;
ret = av_exif_ifd_to_dict(logctx, &ifd, metadata);
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-09-25 0:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-25 0:43 [FFmpeg-devel] [PATCH] avcodec/exif: avoid printing errors for makernote non-IFD parsing (PR #20604) Leo Izen via ffmpeg-devel
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 http://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/ http://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