From 5a9afae082f36812a2e7c9e61d8662628b798f41 Mon Sep 17 00:00:00 2001 From: dev Date: Sat, 14 Nov 2026 18:13:22 +0000 Subject: The hook's stdin splitter was authz_split_ws again Object ids and refnames never contain whitespace, so the same splitter that reads a rule line reads a push line; the inline copy differed only in naming four whitespace characters where isspace() names them all. One behaviour difference, unreachable: a line separated by a vertical tab or form feed now parses instead of being refused. git emits single spaces, refuses control characters in refnames, and object ids are hex, so neither byte can reach the hook in any position that matters. --- src/hook.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'src/hook.c') 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) { -- cgit v1.2.3