Skip to content

Commit

Permalink
fix input path processing in gufi_query and gufi_unrollup
Browse files Browse the repository at this point in the history
  • Loading branch information
calccrypto committed Oct 27, 2023
1 parent ab7edc8 commit ed6c20a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
15 changes: 7 additions & 8 deletions src/gufi_query/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,17 +666,16 @@ int main(int argc, char *argv[])
return -1;
}

/* enqueue all input paths */
/* enqueue input paths */
for(int i = idx; i < argc; i++) {
/* remove trailing slashes */
size_t len = trailing_non_match_index(argv[i], strlen(argv[i]), "/", 1);

/* root is special case */
if (len == 0) {
argv[i][0] = '/';
len = 1;
size_t len = strlen(argv[i]);
if (!len) {
continue;
}

/* remove trailing slashes */
len = trailing_non_match_index(argv[i] + 1, strlen(argv[i] + 1), "/", 1) + 1;

struct stat st;
if (lstat(argv[i], &st) != 0) {
fprintf(stderr, "Could not stat directory \"%s\"\n", argv[i]);
Expand Down
15 changes: 7 additions & 8 deletions src/gufi_unrollup.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,17 +275,16 @@ int main(int argc, char *argv[]) {
return -1;
}

/* enqueue all input paths */
/* enqueue input paths */
for(int i = idx; i < argc; i++) {
/* remove trailing slashes */
size_t len = trailing_non_match_index(argv[i], strlen(argv[i]), "/", 1);

/* root is special case */
if (len == 0) {
argv[i][0] = '/';
len = 1;
size_t len = strlen(argv[i]);
if (!len) {
continue;
}

/* remove trailing slashes */
len = trailing_non_match_index(argv[i] + 1, strlen(argv[i] + 1), "/", 1) + 1;

struct Unrollup *mywork = malloc(sizeof(struct Unrollup));

/* copy argv[i] into the work item */
Expand Down

0 comments on commit ed6c20a

Please sign in to comment.