w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

commit f64cca2fbec48d2184e7bb5e794afeff0f30fbda
parent a5115f3fa41f4fc9ca9ffbecec967c2d4db38633
Author: ukai <ukai>
Date:   Fri, 15 Nov 2002 15:56:36 +0000

[w3m-dev 03436] Check image size
* file.c (process_img): check w > MAX_IMAGE_SIZE
	(HTMLlineproc2body): check w,h > MAX_IMAGE_SIZE
* fm.h (MAX_IMAGE_SIZE): added
* image.c (getImageSize): check w,h,width,height > MAX_IMAGE_SIZE
From: Hiroyuki Ito <hito@crl.go.jp>

Diffstat:
MChangeLog | 8++++++++
Mfile.c | 8++++++--
Mfm.h | 1+
Mimage.c | 10++++++----
4 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,11 @@ +2002-11-16 Hiroyuki Ito <hito@crl.go.jp> + + * [w3m-dev 03436] Check image size + * file.c (process_img): check w > MAX_IMAGE_SIZE + (HTMLlineproc2body): check w,h > MAX_IMAGE_SIZE + * fm.h (MAX_IMAGE_SIZE): added + * image.c (getImageSize): check w,h,width,height > MAX_IMAGE_SIZE + 2002-11-16 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> * [w3m-dev 03435] save image with SAVE diff --git a/file.c b/file.c @@ -2926,6 +2926,8 @@ process_img(struct parsed_tag *tag, int width) w = (int)(w * image_scale / 100 + 0.5); if (w == 0) w = 1; + else if (w > MAX_IMAGE_SIZE) + w = MAX_IMAGE_SIZE; } } #endif @@ -2938,6 +2940,8 @@ process_img(struct parsed_tag *tag, int width) i = (int)(i * image_scale / 100 + 0.5); if (i == 0) i = 1; + else if (i > MAX_IMAGE_SIZE) + i = MAX_IMAGE_SIZE; } else { i = -1; @@ -4949,8 +4953,8 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit) image->url = parsedURL2Str(&u)->ptr; image->ext = filename_extension(u.file, TRUE); image->cache = NULL; - image->width = w; - image->height = h; + image->width = (w > MAX_IMAGE_SIZE) ? MAX_IMAGE_SIZE: w; + image->height = (h > MAX_IMAGE_SIZE) ? MAX_IMAGE_SIZE: h; image->xoffset = xoffset; image->yoffset = yoffset; image->y = currentLn(buf) - top; diff --git a/fm.h b/fm.h @@ -77,6 +77,7 @@ void bzero(void *, int); #ifdef USE_IMAGE #define MAX_IMAGE 1000 +#define MAX_IMAGE_SIZE 10000 #define DEFAULT_PIXEL_PER_CHAR 7.0 /* arbitrary */ #define DEFAULT_PIXEL_PER_LINE 14.0 /* arbitrary */ diff --git a/image.c b/image.c @@ -630,14 +630,16 @@ getImageSize(ImageCache * cache) if (h == 0) h = 1; if (cache->width < 0 && cache->height < 0) { - cache->width = w; - cache->height = h; + cache->width = (w > MAX_IMAGE_SIZE) ? MAX_IMAGE_SIZE: w; + cache->height = (h > MAX_IMAGE_SIZE) ? MAX_IMAGE_SIZE: h; } else if (cache->width < 0) { - cache->width = (int)((double)cache->height * w / h + 0.5); + int tmp = (int)((double)cache->height * w / h + 0.5); + cache->width = (tmp > MAX_IMAGE_SIZE) ? MAX_IMAGE_SIZE: tmp; } else if (cache->height < 0) { - cache->height = (int)((double)cache->width * h / w + 0.5); + int tmp = (int)((double)cache->width * h / w + 0.5); + cache->height = (tmp > MAX_IMAGE_SIZE) ? MAX_IMAGE_SIZE: tmp; } if (cache->width == 0) cache->width = 1;