From 1dd0dfc5911444522ac38f74bfc919fa3b5efba8 Mon Sep 17 00:00:00 2001 From: im-mi Date: Sat, 24 Sep 2016 14:03:14 -0400 Subject: [PATCH] Read ICO header with proper sign Fixes width/height being read incorrectly when >= 128 --- ext/handle_ico/main.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/handle_ico/main.php b/ext/handle_ico/main.php index 4e53c249..b615a59d 100644 --- a/ext/handle_ico/main.php +++ b/ext/handle_ico/main.php @@ -67,9 +67,9 @@ class IcoFileHandler extends Extension { $image = new Image(); $fp = fopen($filename, "r"); - $header = unpack("snull/stype/scount", fread($fp, 6)); + $header = unpack("Snull/Stype/Scount", fread($fp, 6)); - $subheader = unpack("cwidth/cheight/ccolours/cnull/splanes/sbpp/lsize/loffset", fread($fp, 16)); + $subheader = unpack("Cwidth/Cheight/Ccolours/Cnull/Splanes/Sbpp/Lsize/loffset", fread($fp, 16)); fclose($fp); $width = $subheader['width']; @@ -94,7 +94,7 @@ class IcoFileHandler extends Extension { private function check_contents($file) { if(!file_exists($file)) return false; $fp = fopen($file, "r"); - $header = unpack("snull/stype/scount", fread($fp, 6)); + $header = unpack("Snull/Stype/Scount", fread($fp, 6)); fclose($fp); return ($header['null'] == 0 && ($header['type'] == 0 || $header['type'] == 1)); }