Adopt a patch?

2011-11-08 Thread Michael Ost
I have a patch for a bug that I won't be able to shepherd through the 
patch submission process for some time. The bug is that 
GetFileVersionInfoSize doesn't work for files with path names longer 
than 128 characters.


The patch includes an untried unit test. And I've confirmed the behavior 
in Windows Vista.


We use an older version of Wine, and my boss won't let me take the time 
right now to rework the patch for the newest Wine sources. If someone 
wants to they can take this patch, tweak it for the new wine, update it 
to wine-patch requirements and push it through the system.


Otherwise I'll submit as soon as I can.

Cheers,

Michael Ost
--- wine-1.1.7/dlls/kernel32/file.c.RPM	2011-11-02 14:04:34.0 -0700
+++ wine-1.1.7/dlls/kernel32/file.c	2011-11-02 14:06:42.0 -0700
@@ -2476,8 +2476,29 @@
 {
 /* Now look for the file */
 
-if (!SearchPathA( NULL, name, NULL, sizeof(ofs-szPathName), ofs-szPathName, NULL ))
-goto error;
+#if 1 // todo
+		CHAR pathName[MAX_PATH];
+		DWORD len;
+
+		len = SearchPathA( NULL, name, NULL, MAX_PATH, pathName, NULL );
+		if (len == 0)
+			goto error;
+		lstrcpynA(ofs-szPathName, pathName, sizeof(ofs-szPathName));
+// todo: copy as much as you can into ofs ... and confirm this in windows
+
+		TRACE(found %s\n, debugstr_a(pathName) );
+
+		if (mode  OF_DELETE)
+		{
+			if (!DeleteFileA( pathName )) goto error;
+			TRACE((%s): OF_DELETE return = OK\n, name);
+			return TRUE;
+		}
+
+		handle = LongToHandle(_lopen( pathName, mode ));
+#else
+		if (!SearchPathA( NULL, name, NULL, sizeof(ofs-szPathName), ofs-szPathName, NULL ))
+			goto error;
 
 TRACE(found %s\n, debugstr_a(ofs-szPathName) );
 
@@ -2489,6 +2510,7 @@
 }
 
 handle = LongToHandle(_lopen( ofs-szPathName, mode ));
+#endif
 if (handle == INVALID_HANDLE_VALUE) goto error;
 
 GetFileTime( handle, NULL, NULL, filetime );
--- wine-1.1.7/dlls/kernel32/file16.c.RPM	2011-11-02 14:10:28.0 -0700
+++ wine-1.1.7/dlls/kernel32/file16.c	2011-11-02 15:30:13.0 -0700
@@ -122,6 +122,10 @@
 FILETIME filetime;
 WORD filedatetime[2];
 const char *p, *filename;
+#if 1 // todo
+	CHAR pathName[MAX_PATH];
+	DWORD len;
+#endif
 
 if (!ofs) return HFILE_ERROR;
 
@@ -194,11 +198,32 @@
 
 if (filename)
 {
-BOOL found;
+#if 1 // todo
 char *path = get_search_path();
 
 if (!path) goto error;
-found = SearchPathA( path, filename, NULL, sizeof(ofs-szPathName),
+			len = SearchPathA( path, filename, NULL, MAX_PATH, pathName, NULL );
+			HeapFree( GetProcessHeap(), 0, path );
+			if (len == 0) goto error;
+			lstrcpynA(ofs-szPathName, pathName, sizeof(ofs-szPathName));
+		}
+
+		TRACE(found %s\n, debugstr_a(pathName) );
+
+		if (mode  OF_DELETE)
+		{
+			if (!DeleteFileA( pathName )) goto error;
+			TRACE((%s): OF_DELETE return = OK\n, name);
+			return 1;
+		}
+
+		handle = (HANDLE)_lopen( pathName, mode );
+#else
+			BOOL found;
+			char *path = get_search_path();
+
+			if (!path) goto error;
+			found = SearchPathA( path, filename, NULL, sizeof(ofs-szPathName),
  ofs-szPathName, NULL );
 HeapFree( GetProcessHeap(), 0, path );
 if (!found) goto error;
@@ -214,6 +239,7 @@
 }
 
 handle = (HANDLE)_lopen( ofs-szPathName, mode );
+#endif
 if (handle == INVALID_HANDLE_VALUE) goto error;
 
 GetFileTime( handle, NULL, NULL, filetime );
--- wine-1.1.7/dlls/version/tests/info.c.RPM	2011-11-08 10:31:24.0 -0800
+++ wine-1.1.7/dlls/version/tests/info.c	2011-11-02 16:17:00.0 -0700
@@ -183,6 +183,19 @@
Expected ERROR_RESOURCE_DATA_NOT_FOUND, got %d\n, GetLastError());
 
 DeleteFileA(test.txt);
+
+	static const char* const kVeryLongFileName = c:\\a very very long and absolute pathname that is longer than the one hundred and twenty-eight character limit of the OFSTRUCT szPathName member;
+	create_file(kVeryLongFileName);
+	SetLastError(0xdeadbeef);
+	hdl = 0xcafe;
+	retval = GetFileVersionInfoSizeA(kVeryLongFileName, hdl);
+	ok(retval == 0, Expected 0, got %d\n, retval);
+	ok(hdl == 0, Expected 0, got %d\n, hdl);
+	ok(GetLastError() == ERROR_RESOURCE_DATA_NOT_FOUND ||
+	   GetLastError() == ERROR_BAD_FORMAT || /* win9x */
+	   GetLastError() == ERROR_SUCCESS, /* win2k */
+	   Expected ERROR_RESOURCE_DATA_NOT_FOUND, got %d\n, GetLastError());
+	DeleteFileA(kVeryLongFileName);
 }
 
 static void VersionDwordLong2String(DWORDLONG Version, LPSTR lpszVerString)



Re: Adopt a patch?

2011-11-08 Thread Frédéric Delanoy
On Tue, Nov 8, 2011 at 19:41, Michael Ost m...@museresearch.com wrote:
 I have a patch for a bug that I won't be able to shepherd through the patch
 submission process for some time. The bug is that GetFileVersionInfoSize
 doesn't work for files with path names longer than 128 characters.

 The patch includes an untried unit test. And I've confirmed the behavior in
 Windows Vista.

 We use an older version of Wine, and my boss won't let me take the time
 right now to rework the patch for the newest Wine sources. If someone wants
 to they can take this patch, tweak it for the new wine, update it to
 wine-patch requirements and push it through the system.

 Otherwise I'll submit as soon as I can.

You should probably create a new/update an existing bug in wine
bugzilla and attach your patch there.

Frédéric