diff options
Diffstat (limited to 'src/validate.c')
| -rw-r--r-- | src/validate.c | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/src/validate.c b/src/validate.c index 91be26a..c5d05ab 100644 --- a/src/validate.c +++ b/src/validate.c @@ -77,19 +77,6 @@ static int ci_prefix(const char *line, const char *want) return 1; } -static char *strip(char *s) -{ - char *end; - - while (*s != '\0' && isspace((unsigned char)*s)) - s++; - end = s + strlen(s); - while (end > s && isspace((unsigned char)end[-1])) - end--; - *end = '\0'; - return s; -} - // [section] key = value, last one winning - which is the mistake worth // reporting in a gitconfig. @@ -109,7 +96,7 @@ static int ini_value(const char *path, const char *section, const char *key, if (f == NULL) return -1; while ((len = getline(&line, &cap, f)) != -1) { - char *t = strip(line); + char *t = authz_trim(line); char *eq; if (*t == '\0' || *t == '#' || *t == ';') @@ -124,9 +111,9 @@ static int ini_value(const char *path, const char *section, const char *key, if (eq == NULL) continue; *eq = '\0'; - if (!ci_equal(strip(t), key)) + if (!ci_equal(authz_trim(t), key)) continue; - snprintf(out, outsz, "%s", strip(eq + 1)); + snprintf(out, outsz, "%s", authz_trim(eq + 1)); { // gitconfig allows quoting size_t n = strlen(out); @@ -158,7 +145,7 @@ static int directive_value(const char *path, const char *name, char *out, size_t if (f == NULL) return -1; while ((len = getline(&line, &cap, f)) != -1) { - char *t = strip(line); + char *t = authz_trim(line); char *sp; if (*t == '\0' || *t == '#') @@ -171,7 +158,7 @@ static int directive_value(const char *path, const char *name, char *out, size_t *sp = '\0'; if (!ci_equal(t, name)) continue; - snprintf(out, outsz, "%s", strip(sp + 1)); + snprintf(out, outsz, "%s", authz_trim(sp + 1)); free(line); fclose(f); return 1; @@ -337,7 +324,7 @@ static void check_account(const policy_t *p, validate_opts o) break; } if (nf >= 7 && strcmp(fields[0], "git") == 0) { - char *shell = strip(fields[6]); + char *shell = authz_trim(fields[6]); found = 1; if (strstr(shell, "git-shell") == NULL) @@ -368,7 +355,7 @@ static void check_keys(const policy_t *p, validate_opts o) return; } while ((len = getline(&line, &cap, f)) != -1) { - char *t = strip(line); + char *t = authz_trim(line); char *at; if (*t == '\0' || *t == '#') @@ -426,7 +413,7 @@ static void check_htpasswd(const policy_t *p, validate_opts o) return; } while ((len = getline(&line, &cap, f)) != -1) { - char *t = strip(line); + char *t = authz_trim(line); char *colon; if (*t == '\0' || *t == '#') |
