diff options
author | Martin Pärtel <martin.partel@gmail.com> | 2016-05-03 15:59:41 +0300 |
---|---|---|
committer | Martin Pärtel <martin.partel@gmail.com> | 2016-05-03 18:21:26 +0300 |
commit | f4d05de7420476e6f3b20c67977e99fb55348073 (patch) | |
tree | 1f02a38a6e8c27b8a45547bc2d1ce474653d398c /src/bindfs.c | |
parent | ccc63bf574952059af6de525595d58d76a6e249a (diff) | |
download | bindfs-f4d05de7420476e6f3b20c67977e99fb55348073.tar.gz |
Added error checking to parsing --[ug]id-offset value.
Diffstat (limited to 'src/bindfs.c')
-rw-r--r-- | src/bindfs.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/bindfs.c b/src/bindfs.c index 8ece380..9a5efbe 100644 --- a/src/bindfs.c +++ b/src/bindfs.c @@ -1936,7 +1936,16 @@ int main(int argc, char *argv[]) fprintf(stderr, "Error: You need to be root to use --uid-offset !\n"); return 1; } - settings.uid_offset = strtoul(od.uid_offset, NULL, 10); + if (od.map) { + fprintf(stderr, "Error: Cannot use --uid-offset and --map together!\n"); + return 1; + } + char* endptr = od.uid_offset; + settings.uid_offset = strtoul(od.uid_offset, &endptr, 10); + if (*endptr != '\0') { + fprintf(stderr, "Error: Value of --uid-offset must be a positive integer.\n"); + return 1; + } } if (od.gid_offset) { @@ -1944,7 +1953,16 @@ int main(int argc, char *argv[]) fprintf(stderr, "Error: You need to be root to use --gid-offset !\n"); return 1; } - settings.gid_offset = strtoul(od.gid_offset, NULL, 10); + if (od.map) { + fprintf(stderr, "Error: Cannot use --gid-offset and --map together!\n"); + return 1; + } + char* endptr = od.gid_offset; + settings.gid_offset = strtoul(od.gid_offset, &endptr, 10); + if (*endptr != '\0') { + fprintf(stderr, "Error: Value of --gid-offset must be a positive integer.\n"); + return 1; + } } /* Parse user and group for new creates */ |