Skip to content

Commit

Permalink
Fixed buffer overrun issue detected by address sanitizer.
Browse files Browse the repository at this point in the history
  • Loading branch information
mlundh committed Feb 25, 2021
1 parent 62bba78 commit 3acd6a8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/complete.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ char *el_filename_complete(char *pathname, int *match)
if (ac == 1) {
/* Exactly one match -- finish it off. */
*match = 1;
j = strlen(av[0]) - len + 2;
p = malloc(sizeof(char) * (j + 1));
j = strlen(av[0]) - len + 1;
p = malloc(sizeof(char) * (j + 1));
if (p) {
memcpy(p, av[0] + len, j);
len = strlen(dir) + strlen(av[0]) + 2;
path = malloc(sizeof(char) * len);
len = strlen(dir) + strlen(av[0]) + 2;
path = malloc(sizeof(char) * len);
if (path) {
snprintf(path, len, "%s/%s", dir, av[0]);
snprintf(path, len, "%s/%s", dir, av[0]);
rl_add_slash(path, p);
free(path);
}
Expand Down

0 comments on commit 3acd6a8

Please sign in to comment.