mirror of
https://github.com/troglobit/editline.git
synced 2025-05-05 20:11:12 +08:00
Fixed buffer overrun issue detected by address sanitizer.
This commit is contained in:
parent
62bba78258
commit
3acd6a8b60
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user