follow-up r86195 (Sort of). Make sure the string there can really be exploded before...
authorBrian Wolff <bawolff@users.mediawiki.org>
Sat, 16 Apr 2011 18:34:24 +0000 (18:34 +0000)
committerBrian Wolff <bawolff@users.mediawiki.org>
Sat, 16 Apr 2011 18:34:24 +0000 (18:34 +0000)
I originally had the two variables that r86195 removed there to catch the case of a malformed
png file that didn't have a null byte where it was supposed to. However, just declaring the default
for those variables wouldn't have been enough to prevent the warning from list( blah, blah) = explode(..
So now explicitly check the null byte is there like it should be.

includes/media/PNGMetadataExtractor.php

index a8a576a..9ee5a4a 100644 (file)
@@ -203,6 +203,11 @@ class PNGMetadataExtractor {
                        } elseif ( $chunk_type == 'tEXt' ) {
                                $buf = self::read( $fh, $chunk_size );
 
+                               // In case there is no \x00 which will make explode fail.
+                               if ( strpos( $buf, "\x00" ) === false ) {
+                                       throw new Exception( __METHOD__ . ": Read error on tEXt chunk" );
+                               }
+
                                list( $keyword, $content ) = explode( "\x00", $buf, 2 );
                                if ( $keyword === '' || $content === '' ) {
                                        throw new Exception( __METHOD__ . ": Read error on tEXt chunk" );
@@ -231,6 +236,11 @@ class PNGMetadataExtractor {
                                if ( function_exists( 'gzuncompress' ) ) {
                                        $buf = self::read( $fh, $chunk_size );
 
+                                       // In case there is no \x00 which will make explode fail.
+                                       if ( strpos( $buf, "\x00" ) === false ) {
+                                               throw new Exception( __METHOD__ . ": Read error on zTXt chunk" );
+                                       }
+
                                        list( $keyword, $postKeyword ) = explode( "\x00", $buf, 2 );
                                        if ( $keyword === '' || $postKeyword === '' ) {
                                                throw new Exception( __METHOD__ . ": Read error on zTXt chunk" );