test_csr_authorizer: Fix use-after-free

This commit is contained in:
Nicolas Williams
2023-01-02 21:08:45 -06:00
parent 6cf01fea19
commit 90856e35cc

View File

@@ -174,11 +174,11 @@ authorize(const char *subject, const char *thing)
return ENOMEM; return ENOMEM;
ret = stat_authz(s, thing); ret = stat_authz(s, thing);
free(s);
if (ret == ENOENT) if (ret == ENOENT)
ret = stat_authz(s, "all"); ret = stat_authz(s, "all");
if (ret == ENOENT) if (ret == ENOENT)
ret = EACCES; ret = EACCES;
free(s);
return ret; return ret;
} }
@@ -222,7 +222,7 @@ service(void *ctx,
} }
s = cmd + sizeof("check ") - 1; s = cmd + sizeof("check ") - 1;
subject = tok = strtok_r(s, " ", &next); subject = strtok_r(s, " ", &next);
s = NULL; s = NULL;
while ((tok = strtok_r(s, " ", &next))) { while ((tok = strtok_r(s, " ", &next))) {