Skip to content

Commit 2b647a0

Browse files
bbolligitster
authored andcommitted
utf8.c: avoid char overflow
In ISO C, char constants must be in the range -128..127. Change the BOM constants to char literals to avoid overflow. Signed-off-by: Beat Bolli <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b6d3f5a commit 2b647a0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

utf8.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,10 +566,10 @@ static int has_bom_prefix(const char *data, size_t len,
566566
return data && bom && (len >= bom_len) && !memcmp(data, bom, bom_len);
567567
}
568568

569-
static const char utf16_be_bom[] = {0xFE, 0xFF};
570-
static const char utf16_le_bom[] = {0xFF, 0xFE};
571-
static const char utf32_be_bom[] = {0x00, 0x00, 0xFE, 0xFF};
572-
static const char utf32_le_bom[] = {0xFF, 0xFE, 0x00, 0x00};
569+
static const char utf16_be_bom[] = {'\xFE', '\xFF'};
570+
static const char utf16_le_bom[] = {'\xFF', '\xFE'};
571+
static const char utf32_be_bom[] = {'\0', '\0', '\xFE', '\xFF'};
572+
static const char utf32_le_bom[] = {'\xFF', '\xFE', '\0', '\0'};
573573

574574
int has_prohibited_utf_bom(const char *enc, const char *data, size_t len)
575575
{

0 commit comments

Comments
 (0)