diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2009-06-29 20:27:13 +0200 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2009-06-29 20:27:13 +0200 |
commit | 19f17c94169ea0841b23360a3992f4dae068cdb2 (patch) | |
tree | 00e80e0bc42cc4715cb12c3991c112053e8931d5 /dw/fltkimgbuf.cc | |
parent | 731a3e712e20fddf6561444a3b8613cbfcb47106 (diff) |
check for suspicious image size requests in FltkImgbuf::getScaledBuf()
In addition to the test in html.cc we need to check here for
excessive image sizes because
* images can be scaled preserving their original aspect ratio
by just specifing one dimension
* image sizes can be specified via CSS.
Diffstat (limited to 'dw/fltkimgbuf.cc')
-rw-r--r-- | dw/fltkimgbuf.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/dw/fltkimgbuf.cc b/dw/fltkimgbuf.cc index 680a4f4b..48339b51 100644 --- a/dw/fltkimgbuf.cc +++ b/dw/fltkimgbuf.cc @@ -26,6 +26,8 @@ #include <fltk/draw.h> #include <fltk/Color.h> +#define IMAGE_MAX_AREA (6000 * 6000) + using namespace fltk; namespace dw { @@ -185,6 +187,18 @@ core::Imgbuf* FltkImgbuf::getScaledBuf (int width, int height) } } + /* Check for excessive image sizes which would cause crashes due to + * too big allocations for the image buffer. + * In this case we return a pointer to the unscaled image buffer. + */ + if (width <= 0 || height <= 0 || + width > IMAGE_MAX_AREA / height) { + MSG("FltkImgbuf::getScaledBuf: suspicious image size request %dx%d\n", + width, height); + ref (); + return this; + } + /* This size is not yet used, so a new buffer has to be created. */ FltkImgbuf *sb = new FltkImgbuf (type, width, height, this); scaledBuffers->append (sb); |