]> granicus.if.org Git - php/commitdiff
Fixed bug #66242 (don't assume char is signed)
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Sat, 20 Sep 2014 23:32:31 +0000 (16:32 -0700)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Sat, 20 Sep 2014 23:39:48 +0000 (16:39 -0700)
This fixes a bug in libmagic where a cast to 'char' is assumed to result
in sign extension to occur. However, unqualified 'char' is unsigned on
architectures such as ARM, so the cast needs to be to 'signed char'
explicitly.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
ext/fileinfo/libmagic/apprentice.c

index fd82564bff79f893a5c89187a38ea66ab1759d53..b137405da22084b73ffcd65975a538c0f224452a 100644 (file)
@@ -1269,7 +1269,7 @@ file_signextend(struct magic_set *ms, struct magic *m, uint64_t v)
                 * the sign extension must have happened.
                 */
                case FILE_BYTE:
-                       v = (char) v;
+                       v = (signed char) v;
                        break;
                case FILE_SHORT:
                case FILE_BESHORT: