Huw Davies : winspool.drv: Fix AddPrinterDriverA so that the strings actually get written.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Nov 8 06:42:42 CST 2006


Module: wine
Branch: master
Commit: 1ad05ac7015c8bd49c311c925f00b0ceb9e97171
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=1ad05ac7015c8bd49c311c925f00b0ceb9e97171

Author: Huw Davies <huw at codeweavers.com>
Date:   Tue Nov  7 17:16:29 2006 +0000

winspool.drv: Fix AddPrinterDriverA so that the strings actually get written.

Include the size of the terminating zero in set_reg_szW.

---

 dlls/winspool.drv/info.c |   32 +++++++++++++++++++++++---------
 1 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c
index 180361d..8235fd7 100644
--- a/dlls/winspool.drv/info.c
+++ b/dlls/winspool.drv/info.c
@@ -325,6 +325,20 @@ static LPWSTR strdupW(LPCWSTR p)
     return ret;
 }
 
+/* Returns the number of bytes in an ansi \0\0 terminated string (multi_sz).
+   The result includes all \0s (specifically the last two). */
+static int multi_sz_lenA(const char *str)
+{
+    const char *ptr = str;
+    if(!str) return 0;
+    do
+    {
+        ptr += lstrlenA(ptr) + 1;
+    } while(*ptr);
+
+    return ptr - str + 1;
+}
+
 static void
 WINSPOOL_SetDefaultPrinter(const char *devname, const char *name,BOOL force) {
     char qbuf[200];
@@ -623,7 +637,7 @@ static inline DWORD set_reg_szW(HKEY hke
 {
     if (value)
         return RegSetValueExW(hkey, keyname, 0, REG_SZ, (const BYTE*)value,
-                   lstrlenW(value) * sizeof(WCHAR));
+                              (lstrlenW(value) + 1) * sizeof(WCHAR));
     else
         return ERROR_FILE_NOT_FOUND;
 }
@@ -641,7 +655,7 @@ void WINSPOOL_LoadSystemPrinters(void)
                         data_file[]         = "<datafile?>",
                         config_file[]       = "wineps16",
                         help_file[]         = "<helpfile?>",
-                        dep_file[]          = "<dependend files?>",
+                        dep_file[]          = "<dependent files?>\0",
                         monitor_name[]      = "<monitor name?>",
                         default_data_type[] = "RAW";
 
@@ -4369,16 +4383,16 @@ BOOL WINAPI AddPrinterDriverA(LPSTR pNam
 	return FALSE;
     }
     RegSetValueExA(hkeyName, "Configuration File", 0, REG_SZ, (LPBYTE) di3.pConfigFile,
-		   0);
-    RegSetValueExA(hkeyName, "Data File", 0, REG_SZ, (LPBYTE) di3.pDataFile, 0);
-    RegSetValueExA(hkeyName, "Driver", 0, REG_SZ, (LPBYTE) di3.pDriverPath, 0);
+		   lstrlenA(di3.pConfigFile) + 1);
+    RegSetValueExA(hkeyName, "Data File", 0, REG_SZ, (LPBYTE) di3.pDataFile, lstrlenA(di3.pDataFile) + 1);
+    RegSetValueExA(hkeyName, "Driver", 0, REG_SZ, (LPBYTE) di3.pDriverPath, lstrlenA(di3.pDriverPath) + 1);
     RegSetValueExA(hkeyName, "Version", 0, REG_DWORD, (LPBYTE) &di3.cVersion,
 		   sizeof(DWORD));
-    RegSetValueExA(hkeyName, "Datatype", 0, REG_SZ, (LPBYTE) di3.pDefaultDataType, 0);
+    RegSetValueExA(hkeyName, "Datatype", 0, REG_SZ, (LPBYTE) di3.pDefaultDataType, lstrlenA(di3.pDefaultDataType));
     RegSetValueExA(hkeyName, "Dependent Files", 0, REG_MULTI_SZ,
-		   (LPBYTE) di3.pDependentFiles, 0);
-    RegSetValueExA(hkeyName, "Help File", 0, REG_SZ, (LPBYTE) di3.pHelpFile, 0);
-    RegSetValueExA(hkeyName, "Monitor", 0, REG_SZ, (LPBYTE) di3.pMonitorName, 0);
+                   (LPBYTE) di3.pDependentFiles, multi_sz_lenA(di3.pDependentFiles));
+    RegSetValueExA(hkeyName, "Help File", 0, REG_SZ, (LPBYTE) di3.pHelpFile, lstrlenA(di3.pHelpFile) + 1);
+    RegSetValueExA(hkeyName, "Monitor", 0, REG_SZ, (LPBYTE) di3.pMonitorName, lstrlenA(di3.pMonitorName) + 1);
     RegCloseKey(hkeyName);
     RegCloseKey(hkeyDrivers);
 




More information about the wine-cvs mailing list