summaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
authorBeat Bolli <dev+git@drbeat.li>2018-07-09 19:25:37 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-07-09 21:38:12 (GMT)
commit2b647a05d7223beacba076e45b3920a8621d28e7 (patch)
tree9293b8fd81c795878e0bee0e92f5f66739d8e73e /utf8.c
parentb6d3f5a960c2b5dfe3d8d84e7f4c26e03d721d10 (diff)
downloadgit-2b647a05d7223beacba076e45b3920a8621d28e7.zip
git-2b647a05d7223beacba076e45b3920a8621d28e7.tar.gz
git-2b647a05d7223beacba076e45b3920a8621d28e7.tar.bz2
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 <dev+git@drbeat.li> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/utf8.c b/utf8.c
index d55e20c..982217e 100644
--- a/utf8.c
+++ b/utf8.c
@@ -566,10 +566,10 @@ static int has_bom_prefix(const char *data, size_t len,
return data && bom && (len >= bom_len) && !memcmp(data, bom, bom_len);
}
-static const char utf16_be_bom[] = {0xFE, 0xFF};
-static const char utf16_le_bom[] = {0xFF, 0xFE};
-static const char utf32_be_bom[] = {0x00, 0x00, 0xFE, 0xFF};
-static const char utf32_le_bom[] = {0xFF, 0xFE, 0x00, 0x00};
+static const char utf16_be_bom[] = {'\xFE', '\xFF'};
+static const char utf16_le_bom[] = {'\xFF', '\xFE'};
+static const char utf32_be_bom[] = {'\0', '\0', '\xFE', '\xFF'};
+static const char utf32_le_bom[] = {'\xFF', '\xFE', '\0', '\0'};
int has_prohibited_utf_bom(const char *enc, const char *data, size_t len)
{