summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2017-07-01 14:46:21 -0400
committerLibravatar Drew DeVault <ddevault@vistarmedia.com>2017-07-11 20:07:34 -0400
commit19233ee789091cb51401fe498af98a8a6f5d056a (patch)
tree6dfb6d8b075f41fb1eb4b562d2a38a9444156de0
parentFix #1252 (diff)
downloadsway-19233ee789091cb51401fe498af98a8a6f5d056a.tar.gz
sway-19233ee789091cb51401fe498af98a8a6f5d056a.tar.zst
sway-19233ee789091cb51401fe498af98a8a6f5d056a.zip
Merge pull request #1255 from Hummer12007/policy
Prevent null pointer dereferences with policy allocation failure
-rw-r--r--sway/commands.c6
-rw-r--r--sway/commands/permit.c6
-rw-r--r--sway/security.c6
3 files changed, 9 insertions, 9 deletions
diff --git a/sway/commands.c b/sway/commands.c
index f83b5287..59a6adfb 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -607,10 +607,10 @@ struct cmd_results *config_commands_command(char *exec) {
607 } 607 }
608 if (!policy) { 608 if (!policy) {
609 policy = alloc_command_policy(cmd); 609 policy = alloc_command_policy(cmd);
610 if (!policy) { 610 sway_assert(policy, "Unable to allocate security policy");
611 sway_abort("Unable to allocate security policy"); 611 if (policy) {
612 list_add(config->command_policies, policy);
612 } 613 }
613 list_add(config->command_policies, policy);
614 } 614 }
615 policy->context = context; 615 policy->context = context;
616 616
diff --git a/sway/commands/permit.c b/sway/commands/permit.c
index 66fa4e2a..7a5e06f7 100644
--- a/sway/commands/permit.c
+++ b/sway/commands/permit.c
@@ -65,11 +65,11 @@ struct cmd_results *cmd_permit(int argc, char **argv) {
65 } 65 }
66 66
67 struct feature_policy *policy = get_feature_policy(program); 67 struct feature_policy *policy = get_feature_policy(program);
68 if (assign_perms) { 68 if (policy && assign_perms) {
69 policy->features |= get_features(argc, argv, &error); 69 policy->features |= get_features(argc, argv, &error);
70 sway_log(L_DEBUG, "Permissions granted to %s for features %d",
71 policy->program, policy->features);
70 } 72 }
71 sway_log(L_DEBUG, "Permissions granted to %s for features %d",
72 policy->program, policy->features);
73 73
74 free(program); 74 free(program);
75 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 75 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
diff --git a/sway/security.c b/sway/security.c
index 92de06c1..fcd70f9d 100644
--- a/sway/security.c
+++ b/sway/security.c
@@ -152,10 +152,10 @@ struct feature_policy *get_feature_policy(const char *name) {
152 } 152 }
153 if (!policy) { 153 if (!policy) {
154 policy = alloc_feature_policy(name); 154 policy = alloc_feature_policy(name);
155 if (!policy) { 155 sway_assert(policy, "Unable to allocate security policy");
156 sway_abort("Unable to allocate security policy"); 156 if (policy) {
157 list_add(config->feature_policies, policy);
157 } 158 }
158 list_add(config->feature_policies, policy);
159 } 159 }
160 return policy; 160 return policy;
161} 161}