public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] Cygwin: cygwin_GetCommandLineW/A: don't rely on __argv[0] content
@ 2024-02-01 11:39 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2024-02-01 11:39 UTC (permalink / raw)
To: cygwin-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=bded8091c438d18e1d259864d773891a747c7576
commit bded8091c438d18e1d259864d773891a747c7576
Author: Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Wed Jan 31 13:30:05 2024 +0100
Commit: Corinna Vinschen <corinna@vinschen.de>
CommitDate: Wed Jan 31 20:11:58 2024 +0100
Cygwin: cygwin_GetCommandLineW/A: don't rely on __argv[0] content
Since it's possible to change the __argv array, we should not rely
on __argv[0] actually representing the windows executable path in
any way. Use the real path stored in global_progname instead.
Fixes: 521953a83a885 ("* common.din: Export GetCommandLine{A,W}.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/kernel32.cc | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/winsup/cygwin/kernel32.cc b/winsup/cygwin/kernel32.cc
index 36951f6a87be..f07f80d59ddc 100644
--- a/winsup/cygwin/kernel32.cc
+++ b/winsup/cygwin/kernel32.cc
@@ -419,14 +419,17 @@ static UNICODE_STRING *
ucmd ()
{
static UNICODE_STRING wcmd;
+ tmp_pathbuf tp;
+
if (!wcmd.Buffer)
{
linebuf cmd;
- path_conv real_path (__argv[0]);
+ char *win_progname = tp.c_get ();
+ sys_wcstombs (win_progname, NT_MAX_PATH, global_progname);
av newargv (__argc, __argv);
if (newargv.argc)
{
- cmd.fromargv (newargv, real_path.get_win32 (), true);
+ cmd.fromargv (newargv, win_progname, true);
RtlInitUnicodeString (&wcmd, cmd);
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-02-01 11:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-01 11:39 [newlib-cygwin/main] Cygwin: cygwin_GetCommandLineW/A: don't rely on __argv[0] content Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).