[Mono-list] Process.Start patch

Jerome Laban jlaban@wanadoo.fr
Fri, 28 Feb 2003 00:36:19 +0100


This is a multi-part message in MIME format.

------=_NextPart_000_051D_01C2DEC1.695EF380
Content-Type: multipart/alternative;
	boundary="----=_NextPart_001_051E_01C2DEC1.695EF380"


------=_NextPart_001_051E_01C2DEC1.695EF380
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi there,

    Here is a fix for the overloads of System.Diagnostics.Process.Start, =
the method CreateProcess in processes.c was not checking for the =
executable validity when called with a absolute path. There were also =
two uninitialized variables that now are set to NULL. (would have lead =
to multiple frees in this context)

Could someone commit it if ok ?

An other thing, a null reference should not be sent when the executable =
is not found. How should this be addressed ?

Jerome.
------=_NextPart_001_051E_01C2DEC1.695EF380
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1141" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Hi there,</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; Here is a fix for the overloads =
of <FONT=20
face=3D"Courier New">System.Diagnostics.Process.Start</FONT><FONT =
face=3DTahoma>,=20
the method <FONT face=3D"Courier New">CreateProcess</FONT> in =
</FONT><FONT=20
face=3D"Courier New">processes.c </FONT><FONT face=3DTahoma>was not =
checking for the=20
executable validity when called with a absolute path. There were also =
two=20
uninitialized variables that now are set to NULL. (would have lead to =
multiple=20
frees in this context)</FONT></FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Could someone commit it if ok ?</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>An other thing, a null reference should not be sent =
when the=20
executable is not found. How should this be addressed ?</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Jerome.</FONT></DIV></BODY></HTML>

------=_NextPart_001_051E_01C2DEC1.695EF380--

------=_NextPart_000_051D_01C2DEC1.695EF380
Content-Type: application/octet-stream;
	name="processes.c.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="processes.c.diff"

Index: mono/io-layer/processes.c=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /mono/mono/mono/io-layer/processes.c,v=0A=
retrieving revision 1.11=0A=
diff -u -r1.11 processes.c=0A=
--- mono/io-layer/processes.c	21 Feb 2003 13:22:10 -0000	1.11=0A=
+++ mono/io-layer/processes.c	27 Feb 2003 23:35:14 -0000=0A=
@@ -89,7 +89,7 @@=0A=
 			WapiStartupInfo *startup,=0A=
 			WapiProcessInformation *process_info)=0A=
 {=0A=
-	gchar *cmd=3DNULL, *prog, *full_prog, *args=3DNULL, =
*args_after_prog=3DNULL, *dir=3DNULL;=0A=
+	gchar *cmd=3DNULL, *prog =3D NULL, *full_prog =3D NULL, *args=3DNULL, =
*args_after_prog=3DNULL, *dir=3DNULL;=0A=
 	guint32 env=3D0, stored_dir=3D0, stored_prog=3D0, i;=0A=
 	gboolean ret=3DFALSE;=0A=
 	gpointer stdin_handle, stdout_handle, stderr_handle;=0A=
@@ -328,6 +328,17 @@=0A=
 		if(token[0]=3D=3D'/') {=0A=
 			/* Assume full path given */=0A=
 			prog=3Dg_strdup (token);=0A=
+			=0A=
+			/* Executable existing ? */=0A=
+			if(access (prog, X_OK)!=3D0) {=0A=
+				g_free (prog);=0A=
+#ifdef DEBUG=0A=
+				g_message (G_GNUC_PRETTY_FUNCTION ": Couldn't find executable %s", =
token);=0A=
+#endif=0A=
+				g_free (token);=0A=
+				goto cleanup;=0A=
+			}=0A=
+=0A=
 		} else {=0A=
 			char *curdir=3Dg_get_current_dir ();=0A=
 =0A=

------=_NextPart_000_051D_01C2DEC1.695EF380--