diff options
author | LoveSy <shana@zju.edu.cn> | 2021-12-15 17:30:11 +0800 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2021-12-28 20:11:11 +1100 |
commit | c0c2e115f82ed3bc5f9d3f9e5380f0f7e81a1c21 (patch) | |
tree | 1945a091c938d70ffc1511983085b4d64cfe9262 /libfdt/TODO | |
parent | cd5f69cbc0d4bc34a509b5f6f62234e25893b684 (diff) | |
download | dtc-c0c2e115f82ed3bc5f9d3f9e5380f0f7e81a1c21.zip dtc-c0c2e115f82ed3bc5f9d3f9e5380f0f7e81a1c21.tar.gz dtc-c0c2e115f82ed3bc5f9d3f9e5380f0f7e81a1c21.tar.bz2 |
Fix a UB when fdt_get_string return null
When fdt_get_string return null, `namep` is not correctly reset.
From the document of `fdt_getprop_by_offset`, the parameter `namep` will
be always overwritten (that is, it will be overwritten without exception
of error occurance).
As for the caller (like
https://github.com/topjohnwu/Magisk/blob/e097c097feb881f6097b6d1dc346f310bc92f5d6/native/jni/magiskboot/dtb.cpp#L42),
the code may be like:
```cpp
size_t size;
const char *name;
auto *value = fdt_getprop_by_offset(fdt, prop, &name, &size);
```
and if `value == nullptr`, `size` is also be overwritten correctly but
`name` is not, which is quite inconsistent.
This commit makes sure `name` and `size` behavior consistently (reset to
reasonable value) when error occurs.
Signed-off-by: LoveSy <shana@zju.edu.cn>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'libfdt/TODO')
0 files changed, 0 insertions, 0 deletions