media: atomisp: limit the name of the firmware file
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 7 May 2020 18:05:38 +0000 (20:05 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Wed, 20 May 2020 10:32:20 +0000 (12:32 +0200)
The firmware header has 64 bytes. Properly limit it to such
size.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/staging/media/atomisp/pci/sh_css_firmware.c

index 2b1f9845177eb8dd0a91a529bb84c3a91c77d27a..3ba9a7d09c9af8bf870b48ed63194fca08d1ea44 100644 (file)
@@ -222,7 +222,7 @@ sh_css_load_firmware(struct device *dev, const char *fw_data,
        firmware_header = (struct firmware_header *)fw_data;
        file_header = &firmware_header->file_header;
        binaries = &firmware_header->binary_header;
-       strncpy(FW_rel_ver_name, file_header->version, min(sizeof(FW_rel_ver_name), sizeof(file_header->version)) - 1);
+       strscpy(FW_rel_ver_name, file_header->version, min(sizeof(FW_rel_ver_name), sizeof(file_header->version)));
        valid_firmware = sh_css_check_firmware_version(dev, fw_data);
        if (!valid_firmware) {
                IA_CSS_ERROR("CSS code version (%s) and firmware version (%s) mismatch!",