summaryrefslogtreecommitdiffstats
path: root/src/hook.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/hook.c')
-rw-r--r--src/hook.c30
1 files changed, 8 insertions, 22 deletions
diff --git a/src/hook.c b/src/hook.c
index c43f1e3..ffad0bf 100644
--- a/src/hook.c
+++ b/src/hook.c
@@ -314,34 +314,20 @@ int cmd_authorize(const policy_t *p, hook_opts o, int argc, char **argv)
head = head_ref(o, &head_unknown);
while ((len = getline(&line, &cap, stdin)) != -1) {
- char *fields[4];
- int nf = 0;
+ char *fields[3];
+ int nf;
char *ref;
char *old;
char *new;
level_t need;
decision_t d;
- // Split by hand: object ids and refnames never contain whitespace, and
- // this keeps the reader's index the same as the writer's.
-
- {
- char *q = line;
-
- while (*q != '\0') {
- while (*q == ' ' || *q == '\t' || *q == '\n' || *q == '\r')
- q++;
- if (*q == '\0')
- break;
- fields[nf++] = q;
- while (*q != '\0' && *q != ' ' && *q != '\t' && *q != '\n' && *q != '\r')
- q++;
- if (*q != '\0')
- *q++ = '\0';
- if (nf == 4)
- break;
- }
- }
+ // Object ids and refnames never contain whitespace, so the same splitter
+ // that reads a rule line reads one of these. More than three fields
+ // comes back as 4, which the check below refuses rather than reading
+ // past the array.
+
+ nf = authz_split_ws(line, fields, 3);
if (nf == 0)
continue;
if (nf != 3) {