summaryrefslogtreecommitdiff
path: root/bin/systrace/policy.c
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2002-12-09 07:23:53 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2002-12-09 07:23:53 +0000
commit6f42ccbce41012b8903ef41f6dbcea306344b5f8 (patch)
treec1b6c55c9b066d580370f76ffdc7ebf42bda41b4 /bin/systrace/policy.c
parent29b323982871faf2e7d4f49b6709cd1324d2980c (diff)
better parsing of # comments. from provos
Diffstat (limited to 'bin/systrace/policy.c')
-rw-r--r--bin/systrace/policy.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/bin/systrace/policy.c b/bin/systrace/policy.c
index fbdb57e22d7..6daf5957a9c 100644
--- a/bin/systrace/policy.c
+++ b/bin/systrace/policy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: policy.c,v 1.22 2002/12/09 07:22:53 itojun Exp $ */
+/* $OpenBSD: policy.c,v 1.23 2002/12/09 07:23:52 itojun Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
@@ -481,18 +481,26 @@ static char *
systrace_policyline(char *line)
{
char *p;
+ int quoted = 0;
if ((p = strchr(line, '\n')) == NULL)
return (NULL);
*p = '\0';
- /* Remove comments from the input line */
- p = strchr(line, '#');
- if (p != NULL) {
- if (p != line && *(p-1) == '-')
- p = strchr(p + 1, '#');
- if (p != NULL)
+ /* Remove comments from the input line but ignore # that are part
+ * of the system call name or within quotes.
+ */
+ for (p = line; *p; p++) {
+ if (*p == '"')
+ quoted = quoted ? 0 : 1;
+ if (*p == '#') {
+ if (quoted)
+ continue;
+ if (p != line && *(p-1) == '-')
+ continue;
*p = '\0';
+ break;
+ }
}
/* Remove trailing white space */