dm: passthrough: check romfile path length in command
This patch checks the romfile path length in command line to avoid possible buffer overflow, maximum path supported is 255 characters. Tracked-On: #8439 Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com> Reviewed-by: Jian Jun Chen <jian.jun.chen@intel.com>
This commit is contained in:
parent
b6cea37b49
commit
ce3f31dcb6
|
@ -765,7 +765,11 @@ passthru_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
|||
} else if (!strncmp(opt, "romfile=", 8)) {
|
||||
need_rombar = true;
|
||||
opt += 8;
|
||||
strcpy(rom_file, opt);
|
||||
if (strnlen(opt, PATH_MAX) >= sizeof(rom_file)) {
|
||||
pr_err("romfile path too long, max supported path length is 255");
|
||||
return -EINVAL;
|
||||
}
|
||||
strncpy(rom_file, opt, sizeof(rom_file));
|
||||
} else
|
||||
pr_warn("Invalid passthru options:%s", opt);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue