Index: trunk/extensions/PagedTiffHandler/TiffReader.php |
— | — | @@ -4,6 +4,8 @@ |
5 | 5 | * |
6 | 6 | * @author Sebastian Ulbricht <sebastian.ulbricht@gmx.de> |
7 | 7 | */ |
| 8 | + |
| 9 | + // This is still experimental |
8 | 10 | class TiffReader { |
9 | 11 | protected $time = NULL; |
10 | 12 | protected $file = NULL; |
— | — | @@ -116,6 +118,10 @@ |
117 | 119 | fseek($this->file_handle, $offset, SEEK_SET); |
118 | 120 | // read amount of ifd-entries |
119 | 121 | $entries = unpack($this->short, fread($this->file_handle, 2)); |
| 122 | + if(!is_array($entries) || !isset($entries[1])) { |
| 123 | + $this->the_answer = 0; |
| 124 | + return false; |
| 125 | + } |
120 | 126 | $entries = $entries[1]; |
121 | 127 | |
122 | 128 | $address = $offset + 2 + ($entries * 12); |
— | — | @@ -126,11 +132,16 @@ |
127 | 133 | // run through all entries of this ifd an read them out |
128 | 134 | for($i = 0; $i < $entries; $i++) { |
129 | 135 | $tmp = $this->readIFDEntry(); |
| 136 | + if(!$tmp) { return false; } |
130 | 137 | $this->ifd_offsets[$this->embed_files]['data'][$tmp['tag']] = $tmp; |
131 | 138 | } |
132 | 139 | |
133 | 140 | // set the offset of the next ifd or null if this is the last one |
134 | 141 | $offset = unpack($this->long, fread($this->file_handle, 4)); |
| 142 | + if(!is_array($offset) || !isset($offset[1])) { |
| 143 | + $this->the_answer = 0; |
| 144 | + return false; |
| 145 | + } |
135 | 146 | $offset = $offset[1]; |
136 | 147 | if($offset) { |
137 | 148 | $this->ifd_offsets[]['offset'] = $offset; |
— | — | @@ -175,6 +186,11 @@ |
176 | 187 | $type = unpack($this->short, fread($this->file_handle, 2)); |
177 | 188 | $count = unpack($this->long, fread($this->file_handle, 4)); |
178 | 189 | $value = unpack($this->long, fread($this->file_handle, 4)); |
| 190 | + if(!is_array($tag) || !is_array($type) || !is_array($count) || !is_array($value) || |
| 191 | + !isset($tag[1]) || !isset($type[1]) || !isset($count[1]) || !isset($value[1])) { |
| 192 | + $this->the_answer = 0; |
| 193 | + return false; |
| 194 | + } |
179 | 195 | return array('tag' => $tag[1], |
180 | 196 | 'type' => $type[1], |
181 | 197 | 'count' => $count[1], |