mirror of
https://github.com/dgibson/dtc.git
synced 2025-12-07 13:45:07 -05:00
Fix get_node_by_path string equality check
When determining if to recurse into a node, get_node_by_path does not
check if the length of each node name is equal. If searching for
/foo/baz, this can result in recursing into /foobar because
strneq("foo", "foobar", 3) is true.
This can result in a reference to /foo/baz to be incorrectly set to
/foobar/baz. A test for this was added.
Signed-off-by: Tim Montague <tmontague@ghs.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
548aea2c43
commit
a10cb3c818
3 changed files with 26 additions and 2 deletions
|
|
@ -478,7 +478,8 @@ struct node *get_node_by_path(struct node *tree, const char *path)
|
|||
p = strchr(path, '/');
|
||||
|
||||
for_each_child(tree, child) {
|
||||
if (p && strneq(path, child->name, p-path))
|
||||
if (p && (strlen(child->name) == p-path) &&
|
||||
strneq(path, child->name, p-path))
|
||||
return get_node_by_path(child, p+1);
|
||||
else if (!p && streq(path, child->name))
|
||||
return child;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue