mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Fix unbounded writes
This commit is contained in:
parent
6ec2ac19d0
commit
be4fc0908f
3 changed files with 3 additions and 11 deletions
|
|
@ -408,13 +408,12 @@ static char *match_and_replace(const char *str, const char *pattern, char *devic
|
|||
assert(pattern != NULL);
|
||||
assert(device != NULL);
|
||||
|
||||
char *string = malloc(strlen(device) + PATH_MAX);
|
||||
char *string = strndup(device, PATH_MAX);
|
||||
if (string == NULL)
|
||||
{
|
||||
tio_debug_printf("Failure allocating string memory\n");
|
||||
return NULL;
|
||||
}
|
||||
strcpy(string, device);
|
||||
|
||||
/* 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue