summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Chupin <pavel.v.chupin@intel.com>2013-08-09 19:17:55 +0400
committerPavel Chupin <pavel.v.chupin@intel.com>2013-09-03 13:27:09 +0400
commita21e696d905d12ee17481c5fe2ccbb67571c0572 (patch)
tree7ae551a42a065e102665df8a143efe65d78abe45
parent99b859cf786f208300f7fc3a6fa5b570c3333433 (diff)
downloadbionic-a21e696d905d12ee17481c5fe2ccbb67571c0572.zip
bionic-a21e696d905d12ee17481c5fe2ccbb67571c0572.tar.gz
bionic-a21e696d905d12ee17481c5fe2ccbb67571c0572.tar.bz2
Avoid segfaults if properties are not initialized
Null or constant dereferencing occurs if properties are not initialized. On Android devices it shouldn't happen but can be faced if testing bionic libc.so on Linux host. Change-Id: I8f047cbe17d0e7bcde40ace000a8aa53789c16cb Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
-rw-r--r--libc/bionic/system_properties.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libc/bionic/system_properties.c b/libc/bionic/system_properties.c
index 4c2e5a2..fd56431 100644
--- a/libc/bionic/system_properties.c
+++ b/libc/bionic/system_properties.c
@@ -325,6 +325,8 @@ static void *to_prop_obj(prop_off_t off)
{
if (off > pa_data_size)
return NULL;
+ if (!__system_property_area__)
+ return NULL;
return __system_property_area__->data + off;
}
@@ -384,6 +386,8 @@ static const prop_info *find_property(prop_bt *trie, const char *name,
{
const char *remaining_name = name;
+ if (!trie) return NULL;
+
while (true) {
char *sep = strchr(remaining_name, '.');
bool want_subtree = (sep != NULL);