diff options
author | Stephen Smalley <sds@tycho.nsa.gov> | 2015-02-23 21:13:13 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-02-23 21:13:13 +0000 |
commit | e7d85c664ca5e8c22830140d9f87e3a67ef88202 (patch) | |
tree | 9ae1fd5d9df5f9737527be4840ced09bf8c603b4 | |
parent | eec0aca728aa4e3f1aa79f037f5fdebf306c7b99 (diff) | |
parent | 0f912a1cd9dc2c7bb7aebf40d4a0b58058a2a4ac (diff) | |
download | libselinux-e7d85c664ca5e8c22830140d9f87e3a67ef88202.tar.gz |
am 0f912a1c: libselinux: Reject duplicate keys in seapp_context entries.
* commit '0f912a1cd9dc2c7bb7aebf40d4a0b58058a2a4ac':
libselinux: Reject duplicate keys in seapp_context entries.
-rw-r--r-- | src/android.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/android.c b/src/android.c index 8e39aac..7773489 100644 --- a/src/android.c +++ b/src/android.c @@ -366,6 +366,10 @@ int selinux_android_seapp_context_reload(void) goto err; } } else if (!strcasecmp(name, "user")) { + if (cur->user.str) { + free_seapp_context(cur); + goto err; + } cur->user.str = strdup(value); if (!cur->user.str) { free_seapp_context(cur); @@ -375,12 +379,20 @@ int selinux_android_seapp_context_reload(void) if (cur->user.str[cur->user.len-1] == '*') cur->user.is_prefix = 1; } else if (!strcasecmp(name, "seinfo")) { + if (cur->seinfo) { + free_seapp_context(cur); + goto err; + } cur->seinfo = strdup(value); if (!cur->seinfo) { free_seapp_context(cur); goto oom; } } else if (!strcasecmp(name, "name")) { + if (cur->name.str) { + free_seapp_context(cur); + goto err; + } cur->name.str = strdup(value); if (!cur->name.str) { free_seapp_context(cur); @@ -390,18 +402,30 @@ int selinux_android_seapp_context_reload(void) if (cur->name.str[cur->name.len-1] == '*') cur->name.is_prefix = 1; } else if (!strcasecmp(name, "domain")) { + if (cur->domain) { + free_seapp_context(cur); + goto err; + } cur->domain = strdup(value); if (!cur->domain) { free_seapp_context(cur); goto oom; } } else if (!strcasecmp(name, "type")) { + if (cur->type) { + free_seapp_context(cur); + goto err; + } cur->type = strdup(value); if (!cur->type) { free_seapp_context(cur); goto oom; } } else if (!strcasecmp(name, "levelFromUid")) { + if (cur->levelFrom) { + free_seapp_context(cur); + goto err; + } if (!strcasecmp(value, "true")) cur->levelFrom = LEVELFROM_APP; else if (!strcasecmp(value, "false")) @@ -411,6 +435,10 @@ int selinux_android_seapp_context_reload(void) goto err; } } else if (!strcasecmp(name, "levelFrom")) { + if (cur->levelFrom) { + free_seapp_context(cur); + goto err; + } if (!strcasecmp(value, "none")) cur->levelFrom = LEVELFROM_NONE; else if (!strcasecmp(value, "app")) @@ -424,12 +452,20 @@ int selinux_android_seapp_context_reload(void) goto err; } } else if (!strcasecmp(name, "level")) { + if (cur->level) { + free_seapp_context(cur); + goto err; + } cur->level = strdup(value); if (!cur->level) { free_seapp_context(cur); goto oom; } } else if (!strcasecmp(name, "path")) { + if (cur->path.str) { + free_seapp_context(cur); + goto err; + } cur->path.str = strdup(value); if (!cur->path.str) { free_seapp_context(cur); |