ACPICA: Unbreak tools build after switching over to strscpy_pad()
Subsystems (2)
Rafael J. Wysocki
maintainerPATCH 1/1 ACPICA: Unbreak tools build after switching over to strscpy_pad()
From: Rafael J. Wysocki <[email protected]>
Commit 97f7d3f9c9ac ("ACPICA: Replace strncpy() with strscpy_pad() in acpi_ut_safe_strncpy()") switched over the ACPICA code in the kernel to using strscpy_pad() instead of a combination of strncpy() and manual NUL-termination of the destination string, but it overlooked the fact that tools also use the code in question and strscpy_pad() is not defined in those builds.
Address that by using the original ACPICA code in non-kernel builds.
--- drivers/acpi/acpica/utnonansi.c | 10 ++++++++++ 1 file changed, 9 insertions(+)
drivers/acpi/acpica/utnonansi.c +9 -0
@@ -168,7 +168,17 @@ void acpi_ut_safe_strncpy(char *dest, ch {/* Always terminate destination string */ +#ifdef __KERNEL__strscpy_pad (dest, source, dest_size); +#else +/* +* strscpy_pad() is not defined in ACPICA tools builds, so use strncpy() +* and directly NUL-terminate the destination string in that case. +*/ +strncpy (dest, source, dest_size); + dest[dest_size -1 ] =0 ; +#endif }#endif
drivers/acpi/acpica/utnonansi.c void acpi_ut_safe_strncpy(char *dest, ch
Quoted 22 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Commit
97f7d3f9c9ac("ACPICA: Replacestrncpy()withstrscpy_pad()inacpi_ut_safe_strncpy()") switched over the ACPICA code in the kernel to usingstrscpy_pad()instead of a combination ofstrncpy()and manual NUL-termination of the destination string, but it overlooked the fact that tools also use the code in question andstrscpy_pad()is not defined in those builds.Address that by using the original ACPICA code in non-kernel builds.
Fixes 97f7d3f9c9ac ("ACPICA: Replace strncpy() with strscpy_pad() in acpi_ut_safe_strncpy()")Reported-by Jiri Slaby <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/acpi/acpica/utnonansi.c | 10 ++++++++++ 1 file changed, 9 insertions(+)drivers/acpi/acpica/utnonansi.c +0
-0@@ -168,7 +168,17 @@ void acpi_ut_safe_strncpy(char *dest, ch
Hmm, how could this become 17, provided you are adding 9 lines to 7 lines? Fixed to 16 and applied -- testing.
Quoted 19 lines
drivers/acpi/acpica/utnonansi.c +9
-0{/* Always terminate destination string */ +#ifdef __KERNEL__strscpy_pad (dest, source, dest_size); +#else +/* +* strscpy_pad() is not defined in ACPICA tools builds, so use strncpy() +* and directly NUL-terminate the destination string in that case. +*/ +strncpy (dest, source, dest_size); + dest[dest_size -1 ] =0 ; +#endif }#endif
Signature · 2 lines
js suse labs
Rafael J. Wysocki
maintainerQuoted 21 lines · Jiri Slaby
Quoted 19 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Commit
97f7d3f9c9ac("ACPICA: Replacestrncpy()withstrscpy_pad()inacpi_ut_safe_strncpy()") switched over the ACPICA code in the kernel to usingstrscpy_pad()instead of a combination ofstrncpy()and manual NUL-termination of the destination string, but it overlooked the fact that tools also use the code in question andstrscpy_pad()is not defined in those builds.Address that by using the original ACPICA code in non-kernel builds.
Fixes 97f7d3f9c9ac ("ACPICA: Replace strncpy() with strscpy_pad() in acpi_ut_safe_strncpy()")Reported-by Jiri Slaby <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/acpi/acpica/utnonansi.c | 10 ++++++++++ 1 file changed, 9 insertions(+)
Quoted 6 lines
drivers/acpi/acpica/utnonansi.c void acpi_ut_safe_strncpy(char *dest, ch
Quoted 3 lines
drivers/acpi/acpica/utnonansi.c +0
-0@@ -168,7 +168,17 @@ void acpi_ut_safe_strncpy(char *dest, chHmm, how could this become 17, provided you are adding 9 lines to 7 lines? Fixed to 16 and applied -- testing.
Yeah, I manually updated the comment and forgot to refresh the patch afterward. Sorry.
Quoted 24 lines
Quoted 9 lines
drivers/acpi/acpica/utnonansi.c +2
-0{/* Always terminate destination string */ +#ifdef __KERNEL__strscpy_pad (dest, source, dest_size); +#else drivers/acpi/acpica/utnonansi.c void acpi_ut_safe_strncpy(char *dest, ch · line 183
Quoted 10 lines
drivers/acpi/acpica/utnonansi.c +7
-0+/* +* strscpy_pad() is not defined in ACPICA tools builds, so use strncpy() +* and directly NUL-terminate the destination string in that case. +*/ +strncpy (dest, source, dest_size); + dest[dest_size -1 ] =0 ; +#endif }#endif --
js
suse labs
Quoted 8 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Commit
97f7d3f9c9ac("ACPICA: Replacestrncpy()withstrscpy_pad()inacpi_ut_safe_strncpy()") switched over the ACPICA code in the kernel to usingstrscpy_pad()instead of a combination ofstrncpy()and manual NUL-termination of the destination string, but it overlooked the fact that tools also use the code in question andstrscpy_pad()is not defined in those builds.
Eek. Thanks for fixing this! (This looks almost exactly like the shared BPF header solution: non-kernel build just keeps using strncpy.)
Signature · 1 line
Kees Cook