Opened 6 years ago
Last modified 21 months ago
#8030 new enhancement
IMGUTILS, failure handling big images
| Reported by: | gdgsdg123 | Owned by: | |
|---|---|---|---|
| Priority: | wish | Component: | avutil |
| Version: | git-master | Keywords: | |
| Cc: | Blocked By: | ||
| Blocking: | Reproduced by developer: | yes | |
| Analyzed by developer: | no |
Description
Summary of the bug:
[IMGUTILS @ 00000000002ff660] Picture size 9578x27586 is invalid [png @ 00000000029885c0] [IMGUTILS @ 00000000002fee70] Picture size 27586x9578 is invalid [png @ 00000000029885c0] Invalid image size
How to reproduce:
C:\>ffprobe x.png
ffprobe version N-94324-g806ac7da69 Copyright (c) 2007-2019 the FFmpeg developers
built with gcc 9.1.1 (GCC) 20190716
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 30.100 / 56. 30.100
libavcodec 58. 53.101 / 58. 53.101
libavformat 58. 28.102 / 58. 28.102
libavdevice 58. 7.100 / 58. 7.100
libavfilter 7. 56.101 / 7. 56.101
libswscale 5. 4.101 / 5. 4.101
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
[IMGUTILS @ 00000000002ff660] Picture size 9578x27586 is invalid
[png @ 00000000029885c0] [IMGUTILS @ 00000000002fee70] Picture size 27586x9578 is invalid
[png @ 00000000029885c0] Invalid image size
[png_pipe @ 00000000003f3980] Stream #0: not enough frames to estimate rate; consider increasing probesize
[png_pipe @ 00000000003f3980] decoding for stream 0 failed
[png_pipe @ 00000000003f3980] Could not find codec parameters for stream 0 (Video: png, none(pc)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, png_pipe, from 'x.png':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: png, none(pc), 25 tbr, 25 tbn, 25 tbc
Build from: https://zeranoe.com/builds/win64/static/ffmpeg-20190716-806ac7d-win64-static.zip
Also happens on images of similar size (e.g. 16256x16256). The content of the image doesn't seem to matter.
Attachments (1)
Change History (8)
comment:1 by , 6 years ago
| Component: | undetermined → avutil |
|---|---|
| Keywords: | IMGUTILS image size removed |
| Priority: | normal → wish |
follow-up: 3 comment:2 by , 6 years ago
comment:3 by , 6 years ago
Replying to cehoyos:
Replying to gdgsdg123:
The content of the image doesn't seem to matter.
Of course not.
But don't you agree that for whoever is interested in this ticket, a file that shows your actual usecase would make things much easier?
I mean... it seems to occur with any image of a similar size.
comment:4 by , 6 years ago
So why don't you provide one? Just to make it more difficult to fix the issue or is there another reason?
comment:5 by , 6 years ago
Do we really need to clutter the bugtracker with attached files that could be generated in a few seconds with:
rawtoppm 16256 16256 /dev/zero | pnmtopng > big.png
?
comment:6 by , 6 years ago
| Reproduced by developer: | set |
|---|
While the following may be a good idea, it does not help with this issue as the pix_fmt is not yet known when av_image_get_buffer_size() is called.
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index c733cb5cf5..f308422636 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -438,7 +438,7 @@ int av_image_get_buffer_size(enum AVPixelFormat pix_fmt,
if (!desc)
return AVERROR(EINVAL);
- ret = av_image_check_size(width, height, 0, NULL);
+ ret = av_image_check_size2(width, height, INT64_MAX, pix_fmt, 0, NULL);
if (ret < 0)
return ret;
comment:7 by , 21 months ago
This is working for me in Windows x64. In the function av_image_check_size2, just use this:
#if defined(_WIN64)
#define MAX_MEM_SIZE INT64_MAX
#else
#define MAX_MEM_SIZE INT_MAX
#endif
if ((int)w<=0 || (int)h<=0 || stride >= INT_MAX || stride*(uint64_t)(h+128) >= MAX_MEM_SIZE) {
av_log(&imgutils, AV_LOG_ERROR, "Picture size %ux%u is invalid\n", w, h);
return AVERROR(EINVAL);
}



Replying to gdgsdg123:
Of course not.
But don't you agree that for whoever is interested in this ticket, a file that shows your actual usecase would make things much easier?