In case the filename is too long, longer than PATH_MAX - 1, it
would overflow dirs->dirname array. Add missing check and also
use strncpy() to prevent the overflow in any case.
Fixes CID 550305: Security best practices violations (STRING_OVERFLOW)
Signed-off-by: Marek Vasut <marex@denx.de>
struct exfat_node *dnode;
int err;
+ if (strlen(filename) >= PATH_MAX)
+ return -ENAMETOOLONG;
+
err = exfat_lookup_realpath(&ctxt.ef, &dnode, filename);
if (err)
return err;
if (!dirs)
return -ENOMEM;
- strcpy(dirs->dirname, filename);
+ strncpy(dirs->dirname, filename, PATH_MAX - 1);
dirs->offset = -1;
*dirsp = &dirs->fs_dirs;