Skip to content

Commit 893973a

Browse files
committed
Handle fdt splice size errors (addressed Mattia's comment)
1 parent 82142f8 commit 893973a

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ tools/unit-tests/unit-linux-loader-syssize
199199
tools/unit-tests/unit-mpusize
200200
tools/unit-tests/unit-otp-keystore
201201
tools/unit-tests/unit-tpm-api-names
202+
tools/unit-tests/unit-elf-bss-guard
202203

203204

204205
# Elf preprocessing tools

src/fdt.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,15 @@ static void fdt_del_last_string_(void *fdt, const char *s)
281281

282282
static int fdt_splice_(void *fdt, void *splicepoint, int oldlen, int newlen)
283283
{
284+
int data_size;
284285
char *p, *end;
286+
287+
data_size = fdt_data_size_(fdt);
288+
if (data_size < 0)
289+
return data_size;
290+
285291
p = splicepoint;
286-
end = (char*)fdt + fdt_data_size_(fdt);
292+
end = (char*)fdt + data_size;
287293
if (((p + oldlen) < p) || ((p + oldlen) > end)) {
288294
return -FDT_ERR_BADOFFSET;
289295
}

0 commit comments

Comments
 (0)