Found by Linux Device Drivers Verification (Svace detector)
Add terminate symbol for string in any cases.
Signed-off-by: Alexander Strakh <str...@ispras.ru>
---
diff --git a/./0000/drivers/acpi/osl.c b/./0001/drivers/acpi/osl.c
index 02e8464..9c759f8 100644
--- a/./0000/drivers/acpi/osl.c
+++ b/./0001/drivers/acpi/osl.c
@@ -1037,6 +1037,7 @@ int __init acpi_osi_setup(char *str)
acpi_cmdline_osi_linux(1); /* enable */
} else if (*osi_additional_string == '\0') {
strncpy(osi_additional_string, str, OSI_STRING_LENGTH_MAX);
+ osi_additional_string[OSI_STRING_LENGTH_MAX - 1] = 0;
printk(KERN_INFO PREFIX "Added _OSI(%s)\n", str);
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
I guess that's meant to be line 1038?
> 2. In line 1039: if length of str > OSI_STRING_LENGTH_MAX then
> osi_additional_string not have 0 at the end.
> 3. In line 1040 printk called with not null-terminated string.
That printk uses str, not osi_additional_string.
> diff --git a/./0000/drivers/acpi/osl.c b/./0001/drivers/acpi/osl.c
> index 02e8464..9c759f8 100644
> --- a/./0000/drivers/acpi/osl.c
> +++ b/./0001/drivers/acpi/osl.c
> @@ -1037,6 +1037,7 @@ int __init acpi_osi_setup(char *str)
> acpi_cmdline_osi_linux(1); /* enable */
> } else if (*osi_additional_string == '\0') {
> strncpy(osi_additional_string, str, OSI_STRING_LENGTH_MAX);
> + osi_additional_string[OSI_STRING_LENGTH_MAX - 1] = 0;
That will break the test in acpi_os_validate_interface for strings
longer than OSI_STRING_LENGTH_MAX (incl. the NUL byte). And that's the
only other user of osi_additional_string and doesn't require the
terminating NUL byte. So this shouldn't be needed.
Bj�rn