mirror of
https://github.com/tio/tio.git
synced 2026-05-01 23:07:58 +02:00
Fix unbounded writes
This commit is contained in:
parent
6ec2ac19d0
commit
be4fc0908f
3 changed files with 3 additions and 11 deletions
9
src/fs.c
9
src/fs.c
|
|
@ -150,14 +150,7 @@ char* fs_search_directory(const char *dir_path, const char *dirname)
|
|||
// If it's a directory, check if it's the one we're looking for
|
||||
if (strcmp(entry->d_name, dirname) == 0)
|
||||
{
|
||||
char* result = malloc(strlen(path) + 1);
|
||||
if (result == NULL)
|
||||
{
|
||||
// Error allocating memory
|
||||
closedir(dir);
|
||||
return NULL;
|
||||
}
|
||||
strcpy(result, path);
|
||||
char *result = strndup(path, PATH_MAX);
|
||||
closedir(dir);
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue