diff options
| author | dev <dev@example> | 2026-11-14 18:13:22 +0000 |
|---|---|---|
| committer | dev <dev@example> | 2026-11-14 18:13:22 +0000 |
| commit | 5a9afae082f36812a2e7c9e61d8662628b798f41 (patch) | |
| tree | fc71cd1b71ca63db9f262cae0aa23608c88f7c5c /src | |
| parent | 11c976ec713b975568594cf57d9118f58ba8c511 (diff) | |
| download | access-control-5a9afae082f36812a2e7c9e61d8662628b798f41.tar.gz access-control-5a9afae082f36812a2e7c9e61d8662628b798f41.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/hook.c | 30 |
1 files changed, 8 insertions, 22 deletions
@@ -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) { |
