Skip to content

Commit 038886a

Browse files
committed
ext/standard: sync php_hex2bin() with php_random_hex2bin_le()
1 parent c1b8705 commit 038886a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ext/standard/string.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,20 @@ static zend_string *php_hex2bin(const unsigned char *old, const size_t oldlen)
8888
for (i = j = 0; i < target_length; i++) {
8989
unsigned char c = old[j++];
9090
unsigned char l = c & ~0x20;
91-
int is_letter = ((unsigned int) ((l - 'A') ^ (l - 'F' - 1))) >> (8 * sizeof(unsigned int) - 1);
91+
uint32_t is_letter = ((uint32_t) ((l - 'A') ^ (l - 'F' - 1))) >> (8 * sizeof(uint32_t) - 1);
9292
unsigned char d;
9393

9494
/* basically (c >= '0' && c <= '9') || (l >= 'A' && l <= 'F') */
95-
if (EXPECTED((((c ^ '0') - 10) >> (8 * sizeof(unsigned int) - 1)) | is_letter)) {
95+
if (EXPECTED((((c ^ '0') - 10) >> (8 * sizeof(uint32_t) - 1)) | is_letter)) {
9696
d = (l - 0x10 - 0x27 * is_letter) << 4;
9797
} else {
9898
zend_string_efree(str);
9999
return NULL;
100100
}
101101
c = old[j++];
102102
l = c & ~0x20;
103-
is_letter = ((unsigned int) ((l - 'A') ^ (l - 'F' - 1))) >> (8 * sizeof(unsigned int) - 1);
104-
if (EXPECTED((((c ^ '0') - 10) >> (8 * sizeof(unsigned int) - 1)) | is_letter)) {
103+
is_letter = ((uint32_t) ((l - 'A') ^ (l - 'F' - 1))) >> (8 * sizeof(uint32_t) - 1);
104+
if (EXPECTED((((c ^ '0') - 10) >> (8 * sizeof(uint32_t) - 1)) | is_letter)) {
105105
d |= l - 0x10 - 0x27 * is_letter;
106106
} else {
107107
zend_string_efree(str);

0 commit comments

Comments
 (0)