Re: [FFmpeg-devel] [PATCH v2 1/3] libavutil/imgutils: add utility to get plane sizes

2020-07-20 Thread Brian Kim
Just wanted to check if there was any consensus on what we wanted to do with these changes. Are we holding off until a future module wide change? On Wed, Jul 15, 2020 at 8:09 AM James Almer wrote: > On 7/15/2020 4:06 AM, Nicolas George wrote: > > Michael Niedermayer (12020-07-14): > >> Let me ph

Re: [FFmpeg-devel] [PATCH v3 1/4] libavutil/imgutils: add utility to get plane sizes

2020-07-13 Thread Brian Kim
On Mon, Jul 13, 2020 at 11:22 AM James Almer wrote: [...] > You would need to cast height to size_t for this, i think, but seeing > av_image_check_size() currently rejects line sizes and plane sizes > bigger than INT_MAX, maybe we should just keep INT_MAX in the above > check instead (No need to s

[FFmpeg-devel] [PATCH v3 4/4] libavutil/imgutils: check for non-null buffer in av_image_fill_pointers

2020-07-13 Thread Brian Kim
We were previously always filling data by adding offsets to ptr, which was undefined behavior when ptr was NULL. Signed-off-by: Brian Kim --- libavutil/imgutils.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c index 345b7fa94c..721dc2784a

[FFmpeg-devel] [PATCH v3 3/4] libavcodec/decode: avoid UB when getting plane sizes

2020-07-13 Thread Brian Kim
This uses av_image_fill_plane_sizes instead of av_image_fill_pointers when we are getting plane sizes to avoid UB from adding offsets to NULL. Signed-off-by: Brian Kim --- libavcodec/decode.c | 27 +-- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a

[FFmpeg-devel] [PATCH v3 2/4] libavutil/frame: avoid UB when getting plane sizes

2020-07-13 Thread Brian Kim
This uses av_image_fill_plane_sizes instead of av_image_fill_pointers when we are getting plane sizes to avoid UB from adding offsets to NULL. Signed-off-by: Brian Kim --- libavutil/frame.c | 20 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/libavutil

[FFmpeg-devel] [PATCH v3 1/4] libavutil/imgutils: add utility to get plane sizes

2020-07-13 Thread Brian Kim
This utility helps avoid undefined behavior when doing things like checking how much memory we need to allocate for an image before we have allocated a buffer. Signed-off-by: Brian Kim --- doc/APIchanges | 3 ++ libavutil/imgutils.c | 98

Re: [FFmpeg-devel] [PATCH v2 1/3] libavutil/imgutils: add utility to get plane sizes

2020-07-09 Thread Brian Kim
[...] On Wed, Jul 8, 2020 at 7:42 PM James Almer wrote: > The sum of all sizes should be size_t if each size is a size_t. But if > you do that you can't return error values, so i'm not sure what to > suggest other than just stick to ints for both (ptrdiff_t linesizes > should be ok). > I'd like t

Re: [FFmpeg-devel] [PATCH v2 3/3] libavutil/imgutils: check for non-null buffer in av_image_fill_pointer

2020-07-08 Thread Brian Kim
input ptr is null From 2c269118523de0911f17a4b560b016c34fc3002f Mon Sep 17 00:00:00 2001 From: Brian Kim Date: Tue, 7 Jul 2020 11:42:35 -0700 Subject: [PATCH 3/3] libavutil/imgutils: check for non-null buffer in av_image_fill_pointers We were previously always filling data by adding offsets to

[FFmpeg-devel] [PATCH v2 2/3] libavcodec/decode: avoid UB when getting plane sizes

2020-07-08 Thread Brian Kim
Patch attached From 6e28dfde91443fba276fdd792dee9480c0b00558 Mon Sep 17 00:00:00 2001 From: Brian Kim Date: Tue, 7 Jul 2020 11:42:04 -0700 Subject: [PATCH 2/3] libavcodec/decode: avoid UB when getting plane sizes This uses av_image_fill_plane_sizes instead of av_image_fill_pointers when we are

[FFmpeg-devel] [PATCH v2 1/3] libavutil/imgutils: add utility to get plane sizes

2020-07-08 Thread Brian Kim
, but I could not see any mention of these being allowed. From a47b3f3b5c2ed4a1caf9f0a3429dd425ce708bb1 Mon Sep 17 00:00:00 2001 From: Brian Kim Date: Tue, 7 Jul 2020 11:36:19 -0700 Subject: [PATCH 1/3] libavutil/imgutils: add utility to get plane sizes This utility helps avoid undefined behavior

Re: [FFmpeg-devel] libavutil/imgutils: UBSan nullptr-with-offset in av_image_fill_pointer

2020-07-07 Thread Brian Kim
On Tue, Jul 7, 2020 at 4:35 AM Michael Niedermayer wrote: [...] > I wonder if linesizes for newly added functions should be ptrdiff_t > this would add some type converting loops though > > And size probably should be ptrdiff_t or int64_t to similarly be more future > proof Can these values be neg

Re: [FFmpeg-devel] libavutil/imgutils: UBSan nullptr-with-offset in av_image_fill_pointer

2020-07-07 Thread Brian Kim
On Tue, Jul 7, 2020 at 6:34 AM James Almer wrote: > > If i understand this right, you could easily solve it with just the > following changes: > > > diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c > > index 7f9c1b632c..48a373db01 100644 > > --- a/libavutil/imgutils.c > > +++ b/libavutil/i

Re: [FFmpeg-devel] libavutil/imgutils: UBSan nullptr-with-offset in av_image_fill_pointer

2020-07-06 Thread Brian Kim
It looks like this check was added in clang 10 ( https://reviews.llvm.org/D67122) On Thu, Jul 2, 2020 at 8:06 AM Michael Niedermayer wrote: > On Wed, Jul 01, 2020 at 11:14:13AM -0700, Brian Kim wrote: > > While running under Clang's UndefinedBehaviorSanitizer, I found a f

[FFmpeg-devel] libavutil/imgutils: UBSan nullptr-with-offset in av_image_fill_pointer

2020-07-01 Thread Brian Kim
ering if there was interest in avoiding it? I've attached a patch to expose some extra utilities and avoid passing in the null pointer, but is this an appropriate way to work around it? Thank you, Brian From 9db97425b2b3ca0913b7ce8f6f7c096a8aa5c964 Mon Sep 17 00:00:00 2001 From: Brian Kim