Skip to content

Commit

Permalink
don't use dirname() or basename(). They are NOT safe.
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed Nov 6, 2019
1 parent bdc7c02 commit a8f8180
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/bin/unit_test_attribute.c
Expand Up @@ -2328,7 +2328,19 @@ int main(int argc, char *argv[])
int i;

for (i = 1; i < argc; i++) {
ret = process_file(&exit_now, autofree, features, dict, dirname(argv[i]), basename(argv[i]));
char *dir, *file;
char *p = strrchr(argv[i], '/');

if (p) {
*p = '\0'; /* we are allowed to modify our arguments. No one cares. */
dir = argv[i];
file = p + 1;
} else {
dir = NULL;
file = argv[i];
}

ret = process_file(&exit_now, autofree, features, dict, dir, file);
if ((ret != 0) || exit_now) break;
}
}
Expand Down

0 comments on commit a8f8180

Please sign in to comment.