summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2017-07-01 14:46:21 -0400
committerLibravatar GitHub <noreply@github.com>2017-07-01 14:46:21 -0400
commitf745a3b3ef0b575d9a3ea802c338a003b0cc6af5 (patch)
treeaf35993f88080f41b9e2dddb69a20d5152a088ed
parentMerge pull request #1254 from nyorain/master (diff)
parentDo not add empty policies (diff)
downloadsway-f745a3b3ef0b575d9a3ea802c338a003b0cc6af5.tar.gz
sway-f745a3b3ef0b575d9a3ea802c338a003b0cc6af5.tar.zst
sway-f745a3b3ef0b575d9a3ea802c338a003b0cc6af5.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 14be656a..d55d9a96 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -608,10 +608,10 @@ struct cmd_results *config_commands_command(char *exec) {
608 } 608 }
609 if (!policy) { 609 if (!policy) {
610 policy = alloc_command_policy(cmd); 610 policy = alloc_command_policy(cmd);
611 if (!policy) { 611 sway_assert(policy, "Unable to allocate security policy");
612 sway_abort("Unable to allocate security policy"); 612 if (policy) {
613 list_add(config->command_policies, policy);
613 } 614 }
614 list_add(config->command_policies, policy);
615 } 615 }
616 policy->context = context; 616 policy->context = context;
617 617
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}