com php-src: Fixed bug #66242 (don't assume char is signed): ext/fileinfo/libmagic/apprentice.c
| From: | Ard Biesheuvel | Date: | Sat, 20 Sep 2014 23:39:48 +0000 |
| Subject: | com php-src: Fixed bug #66242 (don't assume char is signed): ext/fileinfo/libmagic/apprentice.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-81827@lists.php.net to get a copy of this message | ||
Commit: e64da8c20df3ec28bd2417924b207b870e9ab99f
Author: Ard Biesheuvel <ard.biesheuvel@linaro.org> Sat, 20 Sep 2014 16:32:31 -0700
Parents: 00525b824af4265e7fc74d3655a04da9c4c667f7
Branches: PHP-5.4 PHP-5.5 PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e64da8c20df3ec28bd2417924b207b870e9ab99f
Log:
Fixed bug #66242 (don't assume char is signed)
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>
Bugs:
https://bugs.php.net/66242
Changed paths:
M ext/fileinfo/libmagic/apprentice.c
Diff:
diff --git a/ext/fileinfo/libmagic/apprentice.c b/ext/fileinfo/libmagic/apprentice.c
index fd82564..b137405 100644
--- a/ext/fileinfo/libmagic/apprentice.c
+++ b/ext/fileinfo/libmagic/apprentice.c
@@ -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: