From: Marton Balint <cus@passwd.hu>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH v2 1/2] avcodec: Fix warnings with signed/unsigned compare in bitstream.h
Date: Tue, 28 Mar 2023 21:05:51 +0200 (CEST)
Message-ID: <f47c2cc8-c73-6242-a83a-9d2a4894a946@passwd.hu> (raw)
In-Reply-To: <GV1P250MB0737C035D1377447C9DBE67C8F8B9@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM>
On Mon, 27 Mar 2023, Andreas Rheinhardt wrote:
> Marton Balint:
>>
>>
>> On Sat, 25 Mar 2023, Andreas Rheinhardt wrote:
>>
>>> Devin Heitmueller:
>>>> When including the header in decklink_enc.cpp it would be fed
>>>> through the C++ compiler rather than the C compiler, which has
>>>> more strict warnings when comparing signed/unsigned values.
>>>>
>>>> Make the local variables unsigned to match the arguments they are
>>>> being passed for those functions.
>>>>
>>>> Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
>>>> ---
>>>> libavcodec/bytestream.h | 10 +++++-----
>>>> 1 file changed, 5 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/libavcodec/bytestream.h b/libavcodec/bytestream.h
>>>> index d0033f14f3..67080604b9 100644
>>>> --- a/libavcodec/bytestream.h
>>>> +++ b/libavcodec/bytestream.h
>>>> @@ -180,7 +180,7 @@ static av_always_inline void
>>>> bytestream2_skipu(GetByteContext *g,
>>>> static av_always_inline void bytestream2_skip_p(PutByteContext *p,
>>>> unsigned int size)
>>>> {
>>>> - int size2;
>>>> + unsigned int size2;
>>>> if (p->eof)
>>>> return;
>>>> size2 = FFMIN(p->buffer_end - p->buffer, size);
>>>> @@ -268,7 +268,7 @@ static av_always_inline unsigned int
>>>> bytestream2_get_buffer(GetByteContext *g,
>>>> uint8_t
>>>> *dst,
>>>> unsigned
>>>> int size)
>>>> {
>>>> - int size2 = FFMIN(g->buffer_end - g->buffer, size);
>>>> + unsigned int size2 = FFMIN(g->buffer_end - g->buffer, size);
>>>> memcpy(dst, g->buffer, size2);
>>>> g->buffer += size2;
>>>> return size2;
>>>> @@ -287,7 +287,7 @@ static av_always_inline unsigned int
>>>> bytestream2_put_buffer(PutByteContext *p,
>>>> const
>>>> uint8_t *src,
>>>> unsigned
>>>> int size)
>>>> {
>>>> - int size2;
>>>> + unsigned int size2;
>>>> if (p->eof)
>>>> return 0;
>>>> size2 = FFMIN(p->buffer_end - p->buffer, size);
>>>> @@ -311,7 +311,7 @@ static av_always_inline void
>>>> bytestream2_set_buffer(PutByteContext *p,
>>>> const uint8_t c,
>>>> unsigned int size)
>>>> {
>>>> - int size2;
>>>> + unsigned int size2;
>>>> if (p->eof)
>>>> return;
>>>> size2 = FFMIN(p->buffer_end - p->buffer, size);
>>>> @@ -348,7 +348,7 @@ static av_always_inline unsigned int
>>>> bytestream2_copy_buffer(PutByteContext *p,
>>>>
>>>> GetByteContext *g,
>>>>
>>>> unsigned int size)
>>>> {
>>>> - int size2;
>>>> + unsigned int size2;
>>>>
>>>> if (p->eof)
>>>> return 0;
>>>
>>> The bytestream APIs are allowed to overread if the buffer is padded and
>>> the user manages this himself. So you are not allowed to presume that
>>> g->buffer_end - g->buffer is positive.
>>
>> I am not sure if overread/overwrote is a supported state for these
>> functions. As far as I see bytestream2_get_buffer,
>> bytestream2_put_buffer, bytestream2_copy_buffer and
>> bytestream2_set_buffer just crashes if buffer_end < buffer because
>> sooner or later memcpy/memset gets a negative value. There are no
>> special checks to handle it.
>>
>
> True. Seems like this was never a supported case. Objection lifted.
Ok, will apply.
Regards,
Marton
_______________________________________________
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".
prev parent reply other threads:[~2023-03-28 19:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-17 15:02 Devin Heitmueller
2023-03-17 15:02 ` [FFmpeg-devel] [PATCH v2 2/2] decklink: Add support for compressed AC-3 output over SDI Devin Heitmueller
2023-03-24 21:07 ` Marton Balint
2023-03-27 16:08 ` Devin Heitmueller
2023-03-25 4:47 ` [FFmpeg-devel] [PATCH v2 1/2] avcodec: Fix warnings with signed/unsigned compare in bitstream.h Andreas Rheinhardt
2023-03-25 17:09 ` Marton Balint
2023-03-27 13:12 ` Devin Heitmueller
2023-03-27 13:26 ` Andreas Rheinhardt
2023-03-28 19:05 ` Marton Balint [this message]
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=f47c2cc8-c73-6242-a83a-9d2a4894a946@passwd.hu \
--to=cus@passwd.hu \
--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