Skip to content

Commit e7e6bf7

Browse files
rizlikdanielinux
authored andcommitted
gpt.c: avoid OOB read when utf16 string starts with BOM
1 parent 8d0e455 commit e7e6bf7

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/gpt.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ int gpt_part_name_eq(const uint16_t *utf16_name, const char *ascii_label)
195195
/* Skip BOM if present */
196196
if (utf16_name[utf16_idx] == 0xfeff) {
197197
utf16_idx = 1;
198+
/* Ensure label + BOM offset fits in name array */
199+
if (ascii_len + utf16_idx > GPT_PART_NAME_SIZE) {
200+
return 0;
201+
}
198202
}
199203

200204
/* Compare each character */

0 commit comments

Comments
 (0)