diff mbox series

[FFmpeg-devel,1/2] lavc/vorbis_parser: quiet log on unrecognized packet types

Message ID 20230328203226.34753-1-rcombs@rcombs.me
State New
Headers show
Series [FFmpeg-devel,1/2] lavc/vorbis_parser: quiet log on unrecognized packet types | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

rcombs March 28, 2023, 8:32 p.m. UTC
---
 libavcodec/vorbis_parser.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

James Almer March 28, 2023, 8:42 p.m. UTC | #1
On 3/28/2023 5:32 PM, rcombs wrote:
> ---
>   libavcodec/vorbis_parser.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/vorbis_parser.c b/libavcodec/vorbis_parser.c
> index a7d15d4ce9..65ad3fe2a5 100644
> --- a/libavcodec/vorbis_parser.c
> +++ b/libavcodec/vorbis_parser.c
> @@ -234,7 +234,8 @@ int av_vorbis_parse_frame_flags(AVVorbisParseContext *s, const uint8_t *buf,
>               else if (buf[0] == 5)
>                   *flags |= VORBIS_FLAG_SETUP;
>               else
> -                goto bad_packet;
> +                av_log(s, AV_LOG_VERBOSE, "Ignoring packet with unknown type %i\n",
> +                       buf[0]);
>   
>               /* Special packets have no duration. */
>               return 0;

nit: commit message is wrong since you're not just logging, you're also 
now ignoring them instead of failing. So maybe "lavc/vorbis_parser: 
ignore unrecognized packet types".

LGTM otherwise.
James Almer March 28, 2023, 8:43 p.m. UTC | #2
On 3/28/2023 5:32 PM, rcombs wrote:
> ---
>   libavcodec/vorbis_parser.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/vorbis_parser.c b/libavcodec/vorbis_parser.c
> index a7d15d4ce9..65ad3fe2a5 100644
> --- a/libavcodec/vorbis_parser.c
> +++ b/libavcodec/vorbis_parser.c
> @@ -234,7 +234,8 @@ int av_vorbis_parse_frame_flags(AVVorbisParseContext *s, const uint8_t *buf,
>               else if (buf[0] == 5)
>                   *flags |= VORBIS_FLAG_SETUP;
>               else
> -                goto bad_packet;
> +                av_log(s, AV_LOG_VERBOSE, "Ignoring packet with unknown type %i\n",

Probably should be %u.

> +                       buf[0]);
>   
>               /* Special packets have no duration. */
>               return 0;
James Almer March 28, 2023, 8:44 p.m. UTC | #3
On 3/28/2023 5:32 PM, rcombs wrote:
> Fixes ticket #10289.
> 
> Co-authored-by: James Almer <jamrial@gmail.com>
> ---
>   libavformat/oggparsevorbis.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
> index 061840c2ed..4f48ebabc0 100644
> --- a/libavformat/oggparsevorbis.c
> +++ b/libavformat/oggparsevorbis.c
> @@ -311,7 +311,12 @@ static int vorbis_header(AVFormatContext *s, int idx)
>       if (!(pkt_type & 1))
>           return priv->vp ? 0 : AVERROR_INVALIDDATA;
>   
> -    if (os->psize < 1 || pkt_type > 5)
> +    if (pkt_type > 5) {
> +        av_log(s, AV_LOG_VERBOSE, "Ignoring packet with unknown type %i\n", pkt_type);

nit: we normally use %d for ints.

> +        return 1;
> +    }
> +
> +    if (os->psize < 1)
>           return AVERROR_INVALIDDATA;
>   
>       if (priv->packet[pkt_type >> 1])

LGTM.
diff mbox series

Patch

diff --git a/libavcodec/vorbis_parser.c b/libavcodec/vorbis_parser.c
index a7d15d4ce9..65ad3fe2a5 100644
--- a/libavcodec/vorbis_parser.c
+++ b/libavcodec/vorbis_parser.c
@@ -234,7 +234,8 @@  int av_vorbis_parse_frame_flags(AVVorbisParseContext *s, const uint8_t *buf,
             else if (buf[0] == 5)
                 *flags |= VORBIS_FLAG_SETUP;
             else
-                goto bad_packet;
+                av_log(s, AV_LOG_VERBOSE, "Ignoring packet with unknown type %i\n",
+                       buf[0]);
 
             /* Special packets have no duration. */
             return 0;