This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] [w32] Fix --without-auto-load-safe-path


Hi,

I do not have it tested in real world but from looking at the source I believe
--without-auto-load-safe-path does not work properly on MinGW and it will
always complain with something like:
	warning: File "C:\file.exe-gdb.gdb" auto-loading has been declined by your `auto-load safe-path' set to "".
("" should have allowed any filename.)

On Fedora 16 x86_64 with mingw32-gcc and wine.i686 I have tested with
	#include <stdio.h>
	#include <wtypes.h>
	int
	main (int argc, char **argv)
	{
	  char buf[MAX_PATH];
	  GetFullPathName (argv[1], MAX_PATH, buf, NULL);
	  puts (buf);
	  return 0;
	}

that there is really no / or \ as the first character of absolute filenames:

	$ wine /home/jkratoch/t/realpath.exe realpath.exe
	Z:\tmp\realpath.exe
	$ wine /home/jkratoch/t/realpath.exe /realpath.exe
	Z:\realpath.exe
	$ wine /home/jkratoch/t/realpath.exe c:/realpath.exe
	C:\realpath.exe

No regressions on {x86_64,x86_64-m32,i686}-fedora17-linux-gnu.

A verification on real MS-Windows platform would be helpful but it seems clear
to me to fix such a regression by me.


Thanks,
Jan


gdb/
2012-04-22  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix --without-auto-load-safe-path for MS-Windows host platform.
	* auto-load.c (filename_is_in_dir): Return 1 for DIR_LEN 0.

diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 9d19179..9d4d0bc 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -231,6 +238,12 @@ filename_is_in_dir (const char *filename, const char *dir)
   while (dir_len && IS_DIR_SEPARATOR (dir[dir_len - 1]))
     dir_len--;
 
+  /* Ensure auto_load_safe_path "/" matches any FILENAME.  On MS-Windows
+     platform FILENAME even after gdb_realpath does not have to start with
+     IS_DIR_SEPARATOR character, such as the 'C:\x.exe' filename.  */
+  if (dir_len == 0)
+    return 1;
+
   return (filename_ncmp (dir, filename, dir_len) == 0
 	  && (IS_DIR_SEPARATOR (filename[dir_len])
 	      || filename[dir_len] == '\0'));


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]