mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Fix pattern matching memory corruption
This commit is contained in:
parent
2e86718973
commit
f87f470415
1 changed files with 2 additions and 1 deletions
|
|
@ -428,12 +428,13 @@ static char *match_and_replace(const char *str, const char *pattern, char *devic
|
||||||
assert(pattern != NULL);
|
assert(pattern != NULL);
|
||||||
assert(device != NULL);
|
assert(device != NULL);
|
||||||
|
|
||||||
char *string = strndup(device, PATH_MAX);
|
char *string = calloc(PATH_MAX, 1);
|
||||||
if (string == NULL)
|
if (string == NULL)
|
||||||
{
|
{
|
||||||
tio_debug_printf("Failure allocating string memory\n");
|
tio_debug_printf("Failure allocating string memory\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
strncpy(string, device, PATH_MAX - 1);
|
||||||
|
|
||||||
/* Find matches of pattern in str. For each match, replace any '%mN' in the
|
/* Find matches of pattern in str. For each match, replace any '%mN' in the
|
||||||
* copy of the device string with the corresponding match subexpression and
|
* copy of the device string with the corresponding match subexpression and
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue