New registry key adding patch
Zimler Attila
hijaszu at hlfslinux.hu
Thu Jan 1 05:41:24 CST 2004
Hi,
I tried to remove objectionable codes. Here is the patch again.
I used sprintf, because snprintf gives me a warning, that it is
explicitly declared (stdio.h is included). This is working while "key
name" string is not localized. After that this could introduce security
bugs. Will it be localized? How to deal with situations like this?
Attila
-------------- next part --------------
diff -c -d -r -N wine/programs/regedit/edit.c wine.new_regkey/programs/regedit/edit.c
*** wine/programs/regedit/edit.c 2003-12-12 04:08:59.000000000 +0000
--- wine.new_regkey/programs/regedit/edit.c 2004-01-01 11:30:33.000000000 +0000
***************
*** 91,96 ****
--- 91,120 ----
return FALSE;
}
+ BOOL CreateKey(HKEY hKey)
+ {
+ LONG lRet;
+ HKEY retKey;
+ TCHAR keyName[32];
+ unsigned int keyNum = 1;
+
+ /* If we have illegal parameter return with operation failure */
+ if (!hKey) return FALSE;
+
+ /* try to find out a name for the newly create key.
+ We try it max 100 times. */
+ sprintf(keyName, "new key");
+ lRet = RegOpenKey(hKey, keyName, &retKey);
+ while (lRet == ERROR_SUCCESS && keyNum < 100) {
+ sprintf(keyName, "new key %u", ++keyNum);
+ lRet = RegOpenKey(hKey, keyName, &retKey);
+ }
+ if (lRet != ERROR_SUCCESS) return FALSE;
+
+ lRet = RegCreateKey(hKey, keyName, &retKey);
+ return lRet == ERROR_SUCCESS;
+ }
+
BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName)
{
DWORD valueDataLen;
diff -c -d -r -N wine/programs/regedit/framewnd.c wine.new_regkey/programs/regedit/framewnd.c
*** wine/programs/regedit/framewnd.c 2003-12-12 04:08:59.000000000 +0000
--- wine.new_regkey/programs/regedit/framewnd.c 2004-01-01 11:13:17.000000000 +0000
***************
*** 469,474 ****
--- 469,477 ----
case ID_EDIT_COPYKEYNAME:
CopyKeyName(hWnd, _T(""));
break;
+ case ID_EDIT_NEW_KEY:
+ CreateKey(hKey);
+ break;
case ID_REGISTRY_PRINTERSETUP:
/*PRINTDLG pd;*/
/*PrintDlg(&pd);*/
diff -c -d -r -N wine/programs/regedit/main.h wine.new_regkey/programs/regedit/main.h
*** wine/programs/regedit/main.h 2003-12-12 04:08:59.000000000 +0000
--- wine.new_regkey/programs/regedit/main.h 2004-01-01 11:04:41.000000000 +0000
***************
*** 93,98 ****
--- 93,99 ----
extern LPCTSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey);
/* edit.c */
+ BOOL CreateKey(HKEY hKey);
BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName);
#endif /* __MAIN_H__ */
More information about the wine-devel
mailing list