A collection of small fixes (mostly SAST reports).
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- programs/cmd/wcmdmain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index d5b9eb32799..869bf3962b9 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -3130,7 +3130,7 @@ static void lexer_push_command(struct node_builder *builder, } else { - filename = WCMD_parameter(p + 1, 0, NULL, FALSE, FALSE); + filename = WCMD_parameter(p, 0, NULL, FALSE, FALSE); tkn_pmt.redirection = redirection_create_file(REDIR_READ_FROM, 0, filename); } }
From: Eric Pouech epouech@codeweavers.com
Also resolving a SAST report.
Signed-off-by: Eric Pouech epouech@codeweavers.com --- programs/cmd/batch.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/programs/cmd/batch.c b/programs/cmd/batch.c index 591b3bcd489..035f8accc00 100644 --- a/programs/cmd/batch.c +++ b/programs/cmd/batch.c @@ -536,14 +536,11 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
/* 4. Handle 'z' : File length (File doesn't have to exist) */ if (wmemchr(firstModifier, 'z', modifierLen) != NULL) { - /* FIXME: Output full 64 bit size (sprintf does not support I64 here) */ - ULONG/*64*/ fullsize = /*(fileInfo.nFileSizeHigh << 32) +*/ - fileInfo.nFileSizeLow; - doneModifier = TRUE; if (exists) { + ULONG64 fullsize = ((ULONG64)fileInfo.nFileSizeHigh << 32) | fileInfo.nFileSizeLow; if (finaloutput[0] != 0x00) lstrcatW(finaloutput, L" "); - wsprintfW(thisoutput, L"%u", fullsize); + wsprintfW(thisoutput, L"%I64u", fullsize); lstrcatW(finaloutput, thisoutput); } }
From: Eric Pouech epouech@codeweavers.com
Fixing a SAST report.
Signed-off-by: Eric Pouech epouech@codeweavers.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 db2ced8d5e0..1f613bdfc04 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -3964,7 +3964,7 @@ RETURN_CODE WCMD_mklink(WCHAR *args) WCHAR file1[MAX_PATH]; WCHAR file2[MAX_PATH];
- file1[0] = 0; + file1[0] = file2[0] = L'\0';
while (argN) { WCHAR *thisArg = WCMD_parameter (args, argno++, &argN, FALSE, FALSE);
From: Eric Pouech epouech@codeweavers.com
As reported by SAST.
Note: The out of bounds access is now fixed, but now SAST still reports a false positive.
Signed-off-by: Eric Pouech epouech@codeweavers.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 1f613bdfc04..a446838582f 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -2388,7 +2388,7 @@ RETURN_CODE WCMD_setshow_default(const WCHAR *args) change of directory, even if path was restored due to missing /D (allows changing drive letter when not resident on that drive */ - if ((string[1] == ':') && IsCharAlphaW(string[0])) { + if (IsCharAlphaW(string[0]) && string[1] == L':') { WCHAR env[4]; lstrcpyW(env, L"="); memcpy(env+1, string, 2 * sizeof(WCHAR));
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- programs/cmd/directory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/programs/cmd/directory.c b/programs/cmd/directory.c index 96174a3f4fc..0fb9ad7fdd6 100644 --- a/programs/cmd/directory.c +++ b/programs/cmd/directory.c @@ -922,7 +922,7 @@ RETURN_CODE WCMD_directory(WCHAR *args) } else { /* Special case wildcard search with no extension (ie parameters ending in '.') as GetFullPathName strips off the additional '.' */ - if (fullname[lstrlenW(fullname)-1] == '.') lstrcatW(path, L"."); + if (fullname[0] && fullname[lstrlenW(fullname)-1] == '.') lstrcatW(path, L"."); }
WINE_TRACE("Using path '%s'\n", wine_dbgstr_w(path));