diff options
author | Robert Nagy <robert@cvs.openbsd.org> | 2006-03-18 19:03:24 +0000 |
---|---|---|
committer | Robert Nagy <robert@cvs.openbsd.org> | 2006-03-18 19:03:24 +0000 |
commit | 9e3f87f64b71a261ac7c20fabe32a8b46dfa3ac8 (patch) | |
tree | ec6ec1f91385abb44cadf82fded06335a4c7eb03 | |
parent | 934f7c1306cc745b7ca91e5814225598dcfdf641 (diff) |
fix problems found by Coverity via NetBSD:
- systrace.c: Don't try to dereference pw when it's NULL.
Coverity CID 900
- parse.y: free allocated space on failure Coverity CID 1661
- policy.c: Change a return to "goto out" so that fclose will be called.
Coverity CID 1881
ok sturm@, ray@
-rw-r--r-- | bin/systrace/parse.y | 3 | ||||
-rw-r--r-- | bin/systrace/policy.c | 4 | ||||
-rw-r--r-- | bin/systrace/systrace.c | 10 |
3 files changed, 9 insertions, 8 deletions
diff --git a/bin/systrace/parse.y b/bin/systrace/parse.y index fdf401122a8..f5eddac913f 100644 --- a/bin/systrace/parse.y +++ b/bin/systrace/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.15 2003/07/19 11:48:58 sturm Exp $ */ +/* $OpenBSD: parse.y,v 1.16 2006/03/18 19:03:23 robert Exp $ */ /* * Copyright 2002 Niels Provos <provos@citi.umich.edu> @@ -498,6 +498,7 @@ parse_newsymbol(char *type, int typeoff, char *data) } if (node->filterdata == NULL) { yyerror("strdup"); + free(node); return (NULL); } node->filterlen = strlen(node->filterdata) + 1; diff --git a/bin/systrace/policy.c b/bin/systrace/policy.c index 72c7f685c12..eb8339f0ac4 100644 --- a/bin/systrace/policy.c +++ b/bin/systrace/policy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: policy.c,v 1.29 2003/07/19 11:48:58 sturm Exp $ */ +/* $OpenBSD: policy.c,v 1.30 2006/03/18 19:03:23 robert Exp $ */ /* * Copyright 2002 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -477,7 +477,7 @@ systrace_readtemplate(char *filename, struct policy *policy, } if (policy == NULL) - return (template); + goto out; if (systrace_policyprocess(policy, p) == -1) goto error; diff --git a/bin/systrace/systrace.c b/bin/systrace/systrace.c index 14c2bca91c4..f6a497fb30a 100644 --- a/bin/systrace/systrace.c +++ b/bin/systrace/systrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: systrace.c,v 1.50 2005/05/03 18:03:26 sturm Exp $ */ +/* $OpenBSD: systrace.c,v 1.51 2006/03/18 19:03:23 robert Exp $ */ /* * Copyright 2002 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -87,12 +87,12 @@ systrace_parameters(void) iamroot = getuid() == 0; /* Find out current username. */ - if ((pw = getpwuid(uid)) == NULL) + if ((pw = getpwuid(uid)) == NULL) { snprintf(username, sizeof(username), "uid %u", uid); - else + } else { strlcpy(username, pw->pw_name, sizeof(username)); - - strlcpy(home, pw->pw_dir, sizeof(home)); + strlcpy(home, pw->pw_dir, sizeof(home)); + } /* Determine current working directory for filtering */ if (getcwd(cwd, sizeof(cwd)) == NULL) |