diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-11-15 15:56:36 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-11-15 15:56:36 +0000 |
commit | 6a9b87edf9f730c221762dbe3dceea7f7a71bc08 (patch) | |
tree | b95f5007f381817db044ffad17e19b36d54af8c8 /image.c | |
parent | [w3m-dev 03435] save image with SAVE (diff) | |
download | w3m-6a9b87edf9f730c221762dbe3dceea7f7a71bc08.tar.gz w3m-6a9b87edf9f730c221762dbe3dceea7f7a71bc08.zip |
[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 (limited to '')
-rw-r--r-- | image.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -1,4 +1,4 @@ -/* $Id: image.c,v 1.17 2002/11/15 15:51:24 ukai Exp $ */ +/* $Id: image.c,v 1.18 2002/11/15 15:56:36 ukai Exp $ */ #include "fm.h" #include <sys/types.h> @@ -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; |