diff options
author | Sebastian Pipping <sebastian@pipping.org> | 2023-11-14 00:54:15 +0100 |
---|---|---|
committer | Sebastian Pipping <sebastian@pipping.org> | 2023-11-14 00:59:56 +0100 |
commit | 1136f5bd18ce5b1657347dc26b0aa8e3153786ce (patch) | |
tree | 55372b2fd05926de9c0c6c35acb0554b144ae107 /src | |
parent | f35228177112c1bce0016dbdd0471aca35608b2b (diff) | |
download | bindfs-1136f5bd18ce5b1657347dc26b0aa8e3153786ce.tar.gz |
permchain.c: Address warning -Wunused-parameter
The fix is a near 1:1 copy of what add_chmod_rule_to_permchain
already does about the same problem.
Symptom was:
> src/permchain.c: In function ‘add_octal_rule_to_permchain’:
> src/permchain.c:151:71: error: unused parameter ‘end’ [-Werror=unused-parameter]
> 151 | static int add_octal_rule_to_permchain(const char *start, const char *end,
> |
Diffstat (limited to 'src')
-rw-r--r-- | src/permchain.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/permchain.c b/src/permchain.c index ad32f9d..d101aa1 100644 --- a/src/permchain.c +++ b/src/permchain.c @@ -151,8 +151,18 @@ error: static int add_octal_rule_to_permchain(const char *start, const char *end, struct permchain *pc) { + // Make [start..end[ available as a null-terminated string to `strtol` + const int len = end - start; + char * const buf = malloc((len + 1) * sizeof(char)); + if (buf == NULL) + return -1; + memcpy(buf, start, len); + buf[len] = '\0'; + struct permchain *newpc = permchain_create(); - long mode = strtol(start, NULL, 8); + + long mode = strtol(buf, NULL, 8); + free(buf); if (mode < 0 || mode > 0777) { permchain_destroy(newpc); |