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 v2] tools/target_bsf_fuzzer: simplify the loop feeding packets to the filter
@ 2022-02-25 21:46 James Almer
  2022-02-28 12:27 ` James Almer
  2022-02-28 14:13 ` Michael Niedermayer
  0 siblings, 2 replies; 3+ messages in thread
From: James Almer @ 2022-02-25 21:46 UTC (permalink / raw)
  To: ffmpeg-devel

And use a single AVPacket for the entire process.
This more closely follows the suggested API usage in the doxy.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 tools/target_bsf_fuzzer.c | 41 +++++++++++++++------------------------
 1 file changed, 16 insertions(+), 25 deletions(-)

diff --git a/tools/target_bsf_fuzzer.c b/tools/target_bsf_fuzzer.c
index d6aaee3bd9..8ef9932690 100644
--- a/tools/target_bsf_fuzzer.c
+++ b/tools/target_bsf_fuzzer.c
@@ -43,7 +43,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
     const uint8_t *last = data;
     const uint8_t *end = data + size;
     AVBSFContext *bsf = NULL;
-    AVPacket *in, *out;
+    AVPacket *pkt;
     uint64_t keyframes = 0;
     uint64_t flushpattern = -1;
     int res;
@@ -118,9 +118,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
         return 0; // Failure of av_bsf_init() does not imply that a issue was found
     }
 
-    in = av_packet_alloc();
-    out = av_packet_alloc();
-    if (!in || !out)
+    pkt = av_packet_alloc();
+    if (!pkt)
         error("Failed memory allocation");
 
     while (data < end) {
@@ -133,11 +132,11 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
         if (data + sizeof(fuzz_tag) > end)
             data = end;
 
-        res = av_new_packet(in, data - last);
+        res = av_new_packet(pkt, data - last);
         if (res < 0)
             error("Failed memory allocation");
-        memcpy(in->data, last, data - last);
-        in->flags = (keyframes & 1) * AV_PKT_FLAG_DISCARD + (!!(keyframes & 2)) * AV_PKT_FLAG_KEY;
+        memcpy(pkt->data, last, data - last);
+        pkt->flags = (keyframes & 1) * AV_PKT_FLAG_DISCARD + (!!(keyframes & 2)) * AV_PKT_FLAG_KEY;
         keyframes = (keyframes >> 2) + (keyframes<<62);
         data += sizeof(fuzz_tag);
         last = data;
@@ -146,28 +145,20 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
             av_bsf_flush(bsf);
         flushpattern = (flushpattern >> 3) + (flushpattern << 61);
 
-        while (in->size) {
-            res = av_bsf_send_packet(bsf, in);
-            if (res < 0 && res != AVERROR(EAGAIN))
-                break;
-            res = av_bsf_receive_packet(bsf, out);
-            if (res < 0)
-                break;
-            av_packet_unref(out);
+        res = av_bsf_send_packet(bsf, pkt);
+        if (res < 0) {
+            av_packet_unref(pkt);
+            continue;
         }
-        av_packet_unref(in);
+        while (av_bsf_receive_packet(bsf, pkt) >= 0)
+            av_packet_unref(pkt);
     }
 
-    res = av_bsf_send_packet(bsf, NULL);
-    while (!res) {
-        res = av_bsf_receive_packet(bsf, out);
-        if (res < 0)
-            break;
-        av_packet_unref(out);
-    }
+    av_bsf_send_packet(bsf, NULL);
+    while (av_bsf_receive_packet(bsf, pkt) >= 0)
+        av_packet_unref(pkt);
 
-    av_packet_free(&in);
-    av_packet_free(&out);
+    av_packet_free(&pkt);
     av_bsf_free(&bsf);
     return 0;
 }
-- 
2.35.1

_______________________________________________
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] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2] tools/target_bsf_fuzzer: simplify the loop feeding packets to the filter
  2022-02-25 21:46 [FFmpeg-devel] [PATCH v2] tools/target_bsf_fuzzer: simplify the loop feeding packets to the filter James Almer
@ 2022-02-28 12:27 ` James Almer
  2022-02-28 14:13 ` Michael Niedermayer
  1 sibling, 0 replies; 3+ messages in thread
From: James Almer @ 2022-02-28 12:27 UTC (permalink / raw)
  To: ffmpeg-devel

On 2/25/2022 6:46 PM, James Almer wrote:
> And use a single AVPacket for the entire process.
> This more closely follows the suggested API usage in the doxy.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>   tools/target_bsf_fuzzer.c | 41 +++++++++++++++------------------------
>   1 file changed, 16 insertions(+), 25 deletions(-)

Ping.
_______________________________________________
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] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2] tools/target_bsf_fuzzer: simplify the loop feeding packets to the filter
  2022-02-25 21:46 [FFmpeg-devel] [PATCH v2] tools/target_bsf_fuzzer: simplify the loop feeding packets to the filter James Almer
  2022-02-28 12:27 ` James Almer
@ 2022-02-28 14:13 ` Michael Niedermayer
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Niedermayer @ 2022-02-28 14:13 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 715 bytes --]

On Fri, Feb 25, 2022 at 06:46:30PM -0300, James Almer wrote:
> And use a single AVPacket for the entire process.
> This more closely follows the suggested API usage in the doxy.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  tools/target_bsf_fuzzer.c | 41 +++++++++++++++------------------------
>  1 file changed, 16 insertions(+), 25 deletions(-)

should be ok if tested (for example with a past testcase showing some anomaly)

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: 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] 3+ messages in thread

end of thread, other threads:[~2022-02-28 14:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-25 21:46 [FFmpeg-devel] [PATCH v2] tools/target_bsf_fuzzer: simplify the loop feeding packets to the filter James Almer
2022-02-28 12:27 ` James Almer
2022-02-28 14:13 ` Michael Niedermayer

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