Ensure prop has zero padding

This prevents undesirable behavior if apps directly reads
prop info from devfs node.
This commit is contained in:
canyie 2024-04-12 23:48:29 +08:00 committed by topjohnwu
parent 6663caac22
commit cabe129f54

View File

@ -300,10 +300,10 @@ int SystemProperties::Update(prop_info* pi, const char* value, unsigned int len)
uint32_t serial = atomic_load_explicit(&pi->serial, memory_order_relaxed);
serial |= 1;
atomic_store_explicit(&pi->serial, serial, memory_order_relaxed);
strlcpy(pi->value, value, len + 1);
strncpy(pi->value, value, PROP_VALUE_MAX);
if (have_override) {
atomic_store_explicit(&override_pi->serial, serial, memory_order_relaxed);
strlcpy(override_pi->value, value, len + 1);
strncpy(override_pi->value, value, PROP_VALUE_MAX);
}
// Now the primary value property area is up-to-date. Let readers know that they should
// look at the property value instead of the backup area.