[PATCH] cmd: Ensure new volume label is null-terminated (Coverity)
Alex Henrie
alexhenrie24 at gmail.com
Fri Aug 27 01:44:38 CDT 2021
The command `echo | wine cmd /k 'label c:'` causes WCMD_ReadFile to
return the single character '\n' without a null terminator, which would
then cause garbage to be written to ~/.wine/drive_c/.windows-label.
Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
programs/cmd/builtins.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index c7df724ae00..62ace7510a1 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -4716,8 +4716,8 @@ int WCMD_volume(BOOL set_label, const WCHAR *path)
if (set_label) {
WCMD_output (WCMD_LoadMessage(WCMD_VOLUMEPROMPT));
WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), string, ARRAY_SIZE(string), &count);
+ string[count-1] = '\0'; /* ReadFile output is not null-terminated! */
if (count > 1) {
- string[count-1] = '\0'; /* ReadFile output is not null-terminated! */
if (string[count-2] == '\r') string[count-2] = '\0'; /* Under Windoze we get CRLF! */
}
if (*path) {
--
2.33.0
More information about the wine-devel
mailing list