diff options
author | Chris Johns <chrisj@rtems.org> | 2022-11-25 12:18:07 +1100 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2022-11-25 12:43:29 +1100 |
commit | 408dbeb9225e1969113b81ad3ef484f351b9b4e3 (patch) | |
tree | 9cd6b2df924fa11d53c15e912a69b4c1e8dc1187 /cpukit/libmisc | |
parent | libmisc/shell: Fix edit Coverity error (diff) | |
download | rtems-408dbeb9225e1969113b81ad3ef484f351b9b4e3.tar.bz2 |
libmisc/rtems-fdt: Support prop map items up to the size of uintptr_t
Updates #4729
Diffstat (limited to 'cpukit/libmisc')
-rw-r--r-- | cpukit/libmisc/rtems-fdt/rtems-fdt.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/cpukit/libmisc/rtems-fdt/rtems-fdt.c b/cpukit/libmisc/rtems-fdt/rtems-fdt.c index e5bab21664..ec8f270eef 100644 --- a/cpukit/libmisc/rtems-fdt/rtems-fdt.c +++ b/cpukit/libmisc/rtems-fdt/rtems-fdt.c @@ -1063,18 +1063,33 @@ rtems_fdt_prop_map(const char* const path, return length; } - if (length != sizeof (uintptr_t)) + if (length > sizeof (uintptr_t)) { rtems_fdt_release_handle (&fdt); return -RTEMS_FDT_ERR_BADPATH; } - values[item] = rtems_fdt_get_uintptr(prop); + values[item] = rtems_fdt_get_offset_len_uintptr(prop, 0, length); } return 0; } +uintptr_t +rtems_fdt_get_offset_len_uintptr (const void* prop, int offset, int len) +{ + const uint8_t* p = prop; + uintptr_t value = 0; + int b; + if (len <= sizeof(uintptr_t)) { + for (b = 0; b < len; ++b) { + value = (value << 8) | (uintptr_t) p[offset++]; + } + } + return value; +} + + uint32_t rtems_fdt_get_offset_uint32 (const void* prop, int offset) { |