aboutsummaryrefslogtreecommitdiff
path: root/lib/fstree
diff options
context:
space:
mode:
Diffstat (limited to 'lib/fstree')
-rw-r--r--lib/fstree/fstree_from_dir.c9
-rw-r--r--lib/fstree/get_path.c16
2 files changed, 4 insertions, 21 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;
diff --git a/lib/fstree/get_path.c b/lib/fstree/get_path.c
index f464ade..decf92e 100644
--- a/lib/fstree/get_path.c
+++ b/lib/fstree/get_path.c
@@ -7,11 +7,9 @@
#include "config.h"
#include "fstree.h"
-#include "util.h"
#include <string.h>
#include <stdlib.h>
-#include <errno.h>
char *fstree_get_path(tree_node_t *node)
{
@@ -23,19 +21,14 @@ char *fstree_get_path(tree_node_t *node)
return strdup("/");
for (it = node; it != NULL && it->parent != NULL; it = it->parent) {
- if (SZ_ADD_OV(len, strlen(it->name), &len) ||
- SZ_ADD_OV(len, 1, &len))
- goto fail_ov;
+ len += strlen(it->name) + 1;
}
- if (SZ_ADD_OV(len, 1, &len))
- goto fail_ov;
-
- str = malloc(len);
+ str = malloc(len + 1);
if (str == NULL)
return NULL;
- ptr = str + len - 1;
+ ptr = str + len;
*ptr = '\0';
for (it = node; it != NULL && it->parent != NULL; it = it->parent) {
@@ -47,7 +40,4 @@ char *fstree_get_path(tree_node_t *node)
}
return str;
-fail_ov:
- errno = EOVERFLOW;
- return NULL;
}