lib/device_tree.c: Fix print_property
This uses the size attribute to traverse the possible string. This patch traverses the entire property for non printable characters and not just until the first 0 is hit. Now numbers that start with a zero (memory wise) are not falsely recognized as strings: before the patch: clock-frequency = ""; after the patch: clock-frequency = < 0x1c2000 >; Signed-off-by: Maximilian Brune <maximilian.brune@9elements.com> Change-Id: I229c07b76468fe54f90fa9df12f103d7c7c2859d Reviewed-on: https://review.coreboot.org/c/coreboot/+/78025 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
parent
f7f661f375
commit
77eaec6587
|
@ -75,10 +75,14 @@ static void print_property(const struct fdt_property *prop, int depth)
|
||||||
int is_string = prop->size > 0 &&
|
int is_string = prop->size > 0 &&
|
||||||
((char *)prop->data)[prop->size - 1] == '\0';
|
((char *)prop->data)[prop->size - 1] == '\0';
|
||||||
|
|
||||||
if (is_string)
|
if (is_string) {
|
||||||
for (const char *c = prop->data; *c != '\0'; c++)
|
for (int i = 0; i < prop->size - 1; i++) {
|
||||||
if (!isprint(*c))
|
if (!isprint(((char *)prop->data)[i])) {
|
||||||
is_string = 0;
|
is_string = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
print_indent(depth);
|
print_indent(depth);
|
||||||
if (is_string) {
|
if (is_string) {
|
||||||
|
|
Loading…
Reference in New Issue