diff options
author | Martin Pärtel <martin.partel@gmail.com> | 2023-11-19 21:47:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-19 21:47:34 +0200 |
commit | db61be1897ffe8f4d1a72bed62c8c892d06a1983 (patch) | |
tree | 55372b2fd05926de9c0c6c35acb0554b144ae107 /src/permchain.c | |
parent | 1fdf240aec17b6525ee2ebc76152ea8109f83595 (diff) | |
parent | 1136f5bd18ce5b1657347dc26b0aa8e3153786ce (diff) | |
download | bindfs-db61be1897ffe8f4d1a72bed62c8c892d06a1983.tar.gz |
Merge pull request #148 from hartwork/fix-warnings
Fix compile warnings (including a serious one) + cover FUSE 2 in CI + add `-Wextra` to `configure.ac`
Diffstat (limited to 'src/permchain.c')
-rw-r--r-- | src/permchain.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/permchain.c b/src/permchain.c index b95bd8b..d101aa1 100644 --- a/src/permchain.c +++ b/src/permchain.c @@ -67,6 +67,8 @@ static int add_chmod_rule_to_permchain(const char *start, const char *end, int len = end - start; char *buf = malloc((len + 1) * sizeof(char)); + if (buf == NULL) + return -1; const char *p = buf; enum {LHS, RHS} state = LHS; @@ -149,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); |