diff options
-rw-r--r-- | src/.clang-tidy | 1 | ||||
-rw-r--r-- | src/world.c | 11 | ||||
-rw-r--r-- | tools/.clang-tidy | 1 | ||||
-rw-r--r-- | tools/lv2apply.c | 2 | ||||
-rw-r--r-- | tools/lv2bench.c | 10 |
5 files changed, 18 insertions, 7 deletions
diff --git a/src/.clang-tidy b/src/.clang-tidy index 6fc648d..9cc7cdc 100644 --- a/src/.clang-tidy +++ b/src/.clang-tidy @@ -6,7 +6,6 @@ Checks: > -android-cloexec-fopen, -bugprone-narrowing-conversions, -cert-err33-c, - -cert-err34-c, -clang-analyzer-optin.core.EnumCastOutOfRange, -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, -clang-analyzer-valist.Uninitialized, diff --git a/src/world.c b/src/world.c index c23a34e..42e644c 100644 --- a/src/world.c +++ b/src/world.c @@ -19,6 +19,7 @@ #include <zix/tree.h> #include <assert.h> +#include <limits.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> @@ -733,8 +734,14 @@ get_version(const LilvWorld* world, SordModel* model, const LilvNode* subject) LilvVersion version = {0, 0}; if (minor_node && micro_node) { - version.minor = atoi((const char*)sord_node_get_string(minor_node)); - version.micro = atoi((const char*)sord_node_get_string(micro_node)); + const char* const minor_str = (const char*)sord_node_get_string(minor_node); + const char* const micro_str = (const char*)sord_node_get_string(micro_node); + const long minor = strtol(minor_str, NULL, 10); + const long micro = strtol(micro_str, NULL, 10); + if (minor >= 0 && minor < INT_MAX && micro >= 0 && micro < INT_MAX) { + version.minor = (int)minor; + version.micro = (int)micro; + } } return version; diff --git a/tools/.clang-tidy b/tools/.clang-tidy index d8434e2..406be48 100644 --- a/tools/.clang-tidy +++ b/tools/.clang-tidy @@ -6,7 +6,6 @@ Checks: > -android-cloexec-fopen, -bugprone-narrowing-conversions, -cert-err33-c, - -cert-err34-c, -cppcoreguidelines-avoid-non-const-global-variables, -cppcoreguidelines-narrowing-conversions, -hicpp-signed-bitwise, diff --git a/tools/lv2apply.c b/tools/lv2apply.c index 8fd3753..0792eed 100644 --- a/tools/lv2apply.c +++ b/tools/lv2apply.c @@ -243,7 +243,7 @@ main(int argc, char** argv) self.params = (Param*)realloc(self.params, ++self.n_params * sizeof(Param)); self.params[self.n_params - 1].sym = argv[++i]; - self.params[self.n_params - 1].value = atof(argv[++i]); + self.params[self.n_params - 1].value = strtof(argv[++i], NULL); } else if (argv[i][0] == '-') { free(self.params); return print_usage(1); diff --git a/tools/lv2bench.c b/tools/lv2bench.c index b19d376..fab7ec2 100644 --- a/tools/lv2bench.c +++ b/tools/lv2bench.c @@ -214,9 +214,15 @@ main(int argc, char** argv) if (!strcmp(argv[a], "-f")) { full_output = true; } else if (!strcmp(argv[a], "-n") && (a + 1 < argc)) { - sample_count = atoi(argv[++a]); + const long l = strtol(argv[++a], NULL, 10); + if (l > 0 && l < (1L << 28L)) { + sample_count = (uint32_t)l; + } } else if (!strcmp(argv[a], "-b") && (a + 1 < argc)) { - block_size = atoi(argv[++a]); + const long l = strtol(argv[++a], NULL, 10); + if (l > 0 && l < 16384) { + block_size = (uint32_t)l; + } } else if (argv[a][0] != '-') { break; } else { |