[vlc-devel] [vlc-commits] block: only do the size test when it's meaningful

Steve Lhomme robux4 at ycbcr.xyz
Wed Jul 11 11:21:50 CEST 2018


oops commit. Anyway I think there's something wrong with this check. If 
uintmax_t and size_t have the same size the cast won't check anything. 
Whereas st_size is an off_t which may be bigger than a size_t.


On 2018-07-11 11:13, Steve Lhomme wrote:
> vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Jul 11 08:59:13 2018 +0200| [7a699a45da1e5f622a375cec405b98c3cc5715d3] | committer: Steve Lhomme
>
> block: only do the size test when it's meaningful
>
> If uintmax_t has the same size as size_t then it cannot be bigger than SIZE_MAX
> ever.
>
>> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7a699a45da1e5f622a375cec405b98c3cc5715d3
> ---
>
>   src/misc/block.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/src/misc/block.c b/src/misc/block.c
> index 7d67138768..19e0c07109 100644
> --- a/src/misc/block.c
> +++ b/src/misc/block.c
> @@ -387,12 +387,14 @@ block_t *block_File(int fd, bool write)
>           return NULL;
>       }
>   
> +//#if sizeof(uintmax_t) > sizeof(size_t)
>       /* Prevent an integer overflow in mmap() and malloc() */
>       if ((uintmax_t)st.st_size >= SIZE_MAX)
>       {
>           errno = ENOMEM;
>           return NULL;
>       }
> +//#endif
>       length = (size_t)st.st_size;
>   
>   #ifdef HAVE_MMAP
>
> _______________________________________________
> vlc-commits mailing list
> vlc-commits at videolan.org
> https://mailman.videolan.org/listinfo/vlc-commits



More information about the vlc-devel mailing list