Skip to content

Commit

Permalink
dart: Fix parsing of variable lenght "vm-base" property
Browse files Browse the repository at this point in the history
Signed-off-by: Janne Grunau <[email protected]>
  • Loading branch information
jannau authored and marcan committed May 18, 2024
1 parent dfffdf6 commit 56feda2
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/dart.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,22 @@ dart_dev_t *dart_init_adt(const char *path, int instance, int device, bool keep_
dart->l1[i]);
}
}
if (ADT_GETPROP(adt, node, "vm-base", &dart->vm_base) < 0)
dart->vm_base = 0;
else
u32 len;
const void *prop = adt_getprop(adt, node, "vm-base", &len);
if (prop) {
if (len == sizeof(u32)) {
u32 tmp;
memcpy(&tmp, prop, sizeof(tmp));
dart->vm_base = tmp;
} else if (len == sizeof(u64)) {
u64 tmp;
memcpy(&tmp, prop, sizeof(tmp));
dart->vm_base = tmp;
} else {
printf("dart: unexpected length of vm-base property: %u\n", len);
}
}
if (dart->locked)
dart->vm_base &= (1LLU << 36) - 1;

return dart;
Expand Down

0 comments on commit 56feda2

Please sign in to comment.