Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/5] avformat/apvdec: Use ffio_read_size()
@ 2025-04-28  9:39 Andreas Rheinhardt
  2025-04-30 17:48 ` Andreas Rheinhardt
  2025-04-30 21:15 ` Mark Thompson
  0 siblings, 2 replies; 4+ messages in thread
From: Andreas Rheinhardt @ 2025-04-28  9:39 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

[-- Attachment #1: Type: text/plain, Size: 29 bytes --]

Patches attached.

- Andreas

[-- Attachment #2: 0001-avformat-apvdec-Use-ffio_read_size.patch --]
[-- Type: text/x-patch, Size: 896 bytes --]

From de945d797738c78c3435da1cb64201d00256f702 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Sun, 27 Apr 2025 20:14:35 +0200
Subject: [PATCH 1/5] avformat/apvdec: Use ffio_read_size()

Fixes potential use of uninitialized data.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/apvdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/apvdec.c b/libavformat/apvdec.c
index e1ac34b003..9f94a901ec 100644
--- a/libavformat/apvdec.c
+++ b/libavformat/apvdec.c
@@ -164,7 +164,7 @@ static int apv_read_header(AVFormatContext *s)
     err = ffio_ensure_seekback(s->pb, sizeof(buffer));
     if (err < 0)
         return err;
-    size = avio_read(s->pb, buffer, sizeof(buffer));
+    size = ffio_read_size(s->pb, buffer, sizeof(buffer));
     if (size < 0)
         return size;
 
-- 
2.45.2


[-- Attachment #3: 0002-avformat-apvdec-Check-before-access.patch --]
[-- Type: text/x-patch, Size: 1235 bytes --]

From 3e8f9107090d8bef97b389e8d28ccbe03d3f45f2 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Mon, 28 Apr 2025 11:25:26 +0200
Subject: [PATCH 2/5] avformat/apvdec: Check before access

The signature check would segfault in case the packet could not
be allocated or if nothing could be read.
Furthermore, read_packet callbacks are supposed to return zero
on success, yet the current code returned the size of the packet.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/apvdec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/apvdec.c b/libavformat/apvdec.c
index 9f94a901ec..6a972c6d9a 100644
--- a/libavformat/apvdec.c
+++ b/libavformat/apvdec.c
@@ -225,6 +225,8 @@ static int apv_read_packet(AVFormatContext *s, AVPacket *pkt)
     }
 
     ret = av_get_packet(s->pb, pkt, au_size);
+    if (ret < 0)
+        return ret;
     pkt->flags        = AV_PKT_FLAG_KEY;
 
     signature = AV_RB32(pkt->data);
@@ -233,7 +235,7 @@ static int apv_read_packet(AVFormatContext *s, AVPacket *pkt)
         return AVERROR_INVALIDDATA;
     }
 
-    return ret;
+    return 0;
 }
 
 const FFInputFormat ff_apv_demuxer = {
-- 
2.45.2


[-- Attachment #4: 0003-avformat-apvdec-Fix-seeking.patch --]
[-- Type: text/x-patch, Size: 862 bytes --]

From 87b90d0b6f60d2cd005bd9417f2ecd2f7a781bcd Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Mon, 28 Apr 2025 11:31:49 +0200
Subject: [PATCH 3/5] avformat/apvdec: Fix seeking

pkt->pos pointed to the actual packet data, not to the start
of the access unit.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/apvdec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/apvdec.c b/libavformat/apvdec.c
index 6a972c6d9a..a0a2b7681e 100644
--- a/libavformat/apvdec.c
+++ b/libavformat/apvdec.c
@@ -227,6 +227,7 @@ static int apv_read_packet(AVFormatContext *s, AVPacket *pkt)
     ret = av_get_packet(s->pb, pkt, au_size);
     if (ret < 0)
         return ret;
+    pkt->pos   -= 4;
     pkt->flags        = AV_PKT_FLAG_KEY;
 
     signature = AV_RB32(pkt->data);
-- 
2.45.2


[-- Attachment #5: 0004-avformat-apvdec-Remove-inappropriate-INIT_CLEANUP-fl.patch --]
[-- Type: text/x-patch, Size: 1005 bytes --]

From 5de3c95d8858cc5c133c806e6b45c97103316637 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Sun, 27 Apr 2025 20:20:02 +0200
Subject: [PATCH 4/5] avformat/apvdec: Remove inappropriate INIT_CLEANUP flag

The init-cleanup flag makes no sense for a demuxer without
a read_close() function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/apvdec.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavformat/apvdec.c b/libavformat/apvdec.c
index a0a2b7681e..28948766fc 100644
--- a/libavformat/apvdec.c
+++ b/libavformat/apvdec.c
@@ -244,7 +244,6 @@ const FFInputFormat ff_apv_demuxer = {
     .p.long_name    = NULL_IF_CONFIG_SMALL("APV raw bitstream"),
     .p.extensions   = "apv",
     .p.flags        = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS,
-    .flags_internal = FF_INFMT_FLAG_INIT_CLEANUP,
     .read_probe     = apv_probe,
     .read_header    = apv_read_header,
     .read_packet    = apv_read_packet,
-- 
2.45.2


[-- Attachment #6: 0005-avcodec-apv_entropy-Remove-ff_apv_read_vlc.patch --]
[-- Type: text/x-patch, Size: 1742 bytes --]

From 8701b4e95e040a072e009a21afc3c05883f87c64 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Mon, 28 Apr 2025 11:34:33 +0200
Subject: [PATCH 5/5] avcodec/apv_entropy: Remove ff_apv_read_vlc()

There is no need for testing-only code to exist in release builds,
developers can add testing/debug code just fine locally if they
need it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/apv_decode.h  | 9 ---------
 libavcodec/apv_entropy.c | 6 ------
 2 files changed, 15 deletions(-)

diff --git a/libavcodec/apv_decode.h b/libavcodec/apv_decode.h
index 34c6176ea0..4749116e6b 100644
--- a/libavcodec/apv_decode.h
+++ b/libavcodec/apv_decode.h
@@ -68,13 +68,4 @@ int ff_apv_entropy_decode_block(int16_t *coeff,
                                 GetBitContext *gbc,
                                 APVEntropyState *state);
 
-/**
- * Read a single APV VLC code.
- *
- * This entrypoint is exposed for testing.
- */
-unsigned int ff_apv_read_vlc(GetBitContext *gbc, int k_param,
-                             const APVVLCLUT *lut);
-
-
 #endif /* AVCODEC_APV_DECODE_H */
diff --git a/libavcodec/apv_entropy.c b/libavcodec/apv_entropy.c
index 00e0b4fbdf..0cce6b0847 100644
--- a/libavcodec/apv_entropy.c
+++ b/libavcodec/apv_entropy.c
@@ -95,12 +95,6 @@ static unsigned int apv_read_vlc(GetBitContext *gbc, int k_param,
     }
 }
 
-unsigned int ff_apv_read_vlc(GetBitContext *gbc, int k_param,
-                             const APVVLCLUT *lut)
-{
-    return apv_read_vlc(gbc, k_param, lut);
-}
-
 int ff_apv_entropy_decode_block(int16_t *coeff,
                                 GetBitContext *gbc,
                                 APVEntropyState *state)
-- 
2.45.2


[-- Attachment #7: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/5] avformat/apvdec: Use ffio_read_size()
  2025-04-28  9:39 [FFmpeg-devel] [PATCH 1/5] avformat/apvdec: Use ffio_read_size() Andreas Rheinhardt
@ 2025-04-30 17:48 ` Andreas Rheinhardt
  2025-04-30 21:15 ` Mark Thompson
  1 sibling, 0 replies; 4+ messages in thread
From: Andreas Rheinhardt @ 2025-04-30 17:48 UTC (permalink / raw)
  To: ffmpeg-devel

Andreas Rheinhardt:
> Patches attached.
> 
> - Andreas
> 
Will apply this patchset tomorrow unless there are objections.

- Andreas

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/5] avformat/apvdec: Use ffio_read_size()
  2025-04-28  9:39 [FFmpeg-devel] [PATCH 1/5] avformat/apvdec: Use ffio_read_size() Andreas Rheinhardt
  2025-04-30 17:48 ` Andreas Rheinhardt
@ 2025-04-30 21:15 ` Mark Thompson
  2025-04-30 21:58   ` Andreas Rheinhardt
  1 sibling, 1 reply; 4+ messages in thread
From: Mark Thompson @ 2025-04-30 21:15 UTC (permalink / raw)
  To: ffmpeg-devel

On 28/04/2025 10:39, Andreas Rheinhardt wrote:
> Patches attached.
> 
> - Andreas
> 

> [PATCH 1/5] avformat/apvdec: Use ffio_read_size()

LGTM.

> [PATCH 2/5] avformat/apvdec: Check before access

LGTM.

>     pkt->flags        = AV_PKT_FLAG_KEY;

Not sure where the funny alignment on this line came from (setting some other field there?) but suggest fixing it at the same time as this patch since you edit the previous line and it's not really worth its own patch.

> [PATCH 3/5] avformat/apvdec: Fix seeking

This makes more sense, thank you.  LGTM.

> [PATCH 4/5] avformat/apvdec: Remove inappropriate INIT_CLEANUP flag

Sure.

> [PATCH 5/5] avcodec/apv_entropy: Remove ff_apv_read_vlc()

See patch sent a few minutes ago - suggestions for nicer answer welcome.  (Copy/paste is not a nicer answer.)

Thanks,

- Mark

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/5] avformat/apvdec: Use ffio_read_size()
  2025-04-30 21:15 ` Mark Thompson
@ 2025-04-30 21:58   ` Andreas Rheinhardt
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Rheinhardt @ 2025-04-30 21:58 UTC (permalink / raw)
  To: ffmpeg-devel

Mark Thompson:
> On 28/04/2025 10:39, Andreas Rheinhardt wrote:
>> Patches attached.
>>
>> - Andreas
>>
> 
>> [PATCH 1/5] avformat/apvdec: Use ffio_read_size()
> 
> LGTM.
> 
>> [PATCH 2/5] avformat/apvdec: Check before access
> 
> LGTM.
> 
>>     pkt->flags        = AV_PKT_FLAG_KEY;
> 
> Not sure where the funny alignment on this line came from (setting some other field there?) but suggest fixing it at the same time as this patch since you edit the previous line and it's not really worth its own patch.
> 
>> [PATCH 3/5] avformat/apvdec: Fix seeking
> 
> This makes more sense, thank you.  LGTM.
> 
>> [PATCH 4/5] avformat/apvdec: Remove inappropriate INIT_CLEANUP flag
> 
> Sure.
> 
>> [PATCH 5/5] avcodec/apv_entropy: Remove ff_apv_read_vlc()
> 
> See patch sent a few minutes ago - suggestions for nicer answer welcome.  (Copy/paste is not a nicer answer.)
> 

a) #include "libavcodec/apv_entropy.c" in the test program.
b) Move apv_read_vlc() into a header (apv_decode.h).
I'd prefer a).

- Andreas

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-04-30 21:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-28  9:39 [FFmpeg-devel] [PATCH 1/5] avformat/apvdec: Use ffio_read_size() Andreas Rheinhardt
2025-04-30 17:48 ` Andreas Rheinhardt
2025-04-30 21:15 ` Mark Thompson
2025-04-30 21:58   ` Andreas Rheinhardt

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