mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-02-25 13:57:25 +00:00
Wipe out prop_info data after delete
This commit is contained in:
parent
36765caedc
commit
2fef98a5af
@ -276,11 +276,11 @@ prop_bt* prop_area::find_prop_bt(prop_bt* const bt, const char* name, uint32_t n
|
|||||||
|
|
||||||
/* resetprop new: traverse through the trie and find the node.
|
/* resetprop new: traverse through the trie and find the node.
|
||||||
* This was originally part of prop_area::find_property. */
|
* This was originally part of prop_area::find_property. */
|
||||||
prop_bt *prop_area::find_prop_bt(prop_bt *const trie, const char *name, bool alloc_if_needed) {
|
prop_bt *prop_area::find_prop_bt(prop_bt *const bt, const char *name, bool alloc_if_needed) {
|
||||||
if (!trie) return nullptr;
|
if (!bt) return nullptr;
|
||||||
|
|
||||||
const char* remaining_name = name;
|
const char* remaining_name = name;
|
||||||
prop_bt* current = trie;
|
prop_bt* current = bt;
|
||||||
while (true) {
|
while (true) {
|
||||||
const char* sep = strchr(remaining_name, '.');
|
const char* sep = strchr(remaining_name, '.');
|
||||||
const bool want_subtree = (sep != nullptr);
|
const bool want_subtree = (sep != nullptr);
|
||||||
@ -381,11 +381,30 @@ bool prop_area::add(const char* name, unsigned int namelen, const char* value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool prop_area::rm(const char *name) {
|
bool prop_area::rm(const char *name) {
|
||||||
prop_bt* node = find_prop_bt(root_node(), name, false);
|
prop_bt *node = find_prop_bt(root_node(), name, false);
|
||||||
if (!node)
|
if (!node)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
prop_info *info = nullptr;
|
||||||
|
uint_least32_t prop_offset = atomic_load_explicit(&node->prop, memory_order_relaxed);
|
||||||
|
if (prop_offset != 0) {
|
||||||
|
info = to_prop_info(&node->prop);
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-reference the existing property ASAP
|
||||||
uint_least32_t new_offset = 0;
|
uint_least32_t new_offset = 0;
|
||||||
atomic_store_explicit(&node->prop, new_offset, memory_order_release);
|
atomic_store_explicit(&node->prop, new_offset, memory_order_release);
|
||||||
|
|
||||||
|
if (info) {
|
||||||
|
// Directly wipe out the old info
|
||||||
|
if (info->is_long()) {
|
||||||
|
char *value = const_cast<char*>(info->long_value());
|
||||||
|
auto len = strlen(value);
|
||||||
|
memset(value, 0, len);
|
||||||
|
}
|
||||||
|
memset(info, 0, sizeof(*info));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user