summaryrefslogtreecommitdiff
path: root/lib/fstree/fstree_from_dir.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-26 09:13:59 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-26 09:20:31 +0200
commitf5c0f0c75181d5e7fa56d11fa59a32a1c088020a (patch)
treeff50595ab17bff0350df94880b903eeab8aa9986 /lib/fstree/fstree_from_dir.c
parentc92a9513c9e21691b36868052c2d9489ab4be87b (diff)
Tune the paranoia down a bit
size_t is guaranteed to be large enough to measure the size of things in memory, so when doing exactely that (e.g. strlen(a) + strlen(b)), checking for overflow is pointless since both objects are already in memory. If the addition would overflow, the two strings would occupy more memory than addressable. (Possible exception being some kind of harward style architecture with the two strings being in different kinds of memory of course.) Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/fstree/fstree_from_dir.c')
-rw-r--r--lib/fstree/fstree_from_dir.c9
1 files changed, 1 insertions, 8 deletions
diff --git a/lib/fstree/fstree_from_dir.c b/lib/fstree/fstree_from_dir.c
index d6fac86..9aab5df 100644
--- a/lib/fstree/fstree_from_dir.c
+++ b/lib/fstree/fstree_from_dir.c
@@ -25,7 +25,6 @@
static char *get_file_path(tree_node_t *n, const char *name)
{
char *ptr, *new;
- size_t len;
int ret;
if (n->parent == NULL) {
@@ -42,13 +41,7 @@ static char *get_file_path(tree_node_t *n, const char *name)
ret = canonicalize_name(ptr);
assert(ret == 0);
- if (SZ_ADD_OV(strlen(ptr), strlen(name), &len) ||
- SZ_ADD_OV(len, 2, &len)) {
- errno = EOVERFLOW;
- goto fail;
- }
-
- new = realloc(ptr, len);
+ new = realloc(ptr, strlen(ptr) + strlen(name) + 2);
if (new == NULL)
goto fail;