[commit: packages/Win32] depend-os-windows, fix-appveyor-curl-ussue, master, win32-2.5.4.1-ghc-8.2: regSetValue wasn't null terminated (#39) (4e76f05)

git at git.haskell.org git at git.haskell.org
Mon Apr 17 21:28:40 UTC 2017


Repository : ssh://git@git.haskell.org/Win32

On branches: depend-os-windows,fix-appveyor-curl-ussue,master,win32-2.5.4.1-ghc-8.2
Link       : http://git.haskell.org/packages/Win32.git/commitdiff/4e76f0517137239dcdbc1bb1766d876e9a9505b0

>---------------------------------------------------------------

commit 4e76f0517137239dcdbc1bb1766d876e9a9505b0
Author: Ilan Godik <ilan3580 at gmail.com>
Date:   Mon Mar 13 14:53:52 2017 -0700

    regSetValue wasn't null terminated (#39)


>---------------------------------------------------------------

4e76f0517137239dcdbc1bb1766d876e9a9505b0
 System/Win32/Registry.hsc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/System/Win32/Registry.hsc b/System/Win32/Registry.hsc
index a345544..09fdcb8 100644
--- a/System/Win32/Registry.hsc
+++ b/System/Win32/Registry.hsc
@@ -72,7 +72,7 @@ import System.Win32.File (LPSECURITY_ATTRIBUTES)
 import System.Win32.Time (FILETIME)
 import System.Win32.Types (DWORD, ErrCode, HKEY, LPCTSTR, PKEY, withTString)
 import System.Win32.Types (HANDLE, LONG, LPBYTE, newForeignHANDLE, peekTString)
-import System.Win32.Types (LPTSTR, TCHAR, failUnlessSuccess, withTStringLen)
+import System.Win32.Types (LPTSTR, TCHAR, failUnlessSuccess)
 import System.Win32.Types (castUINTPtrToPtr, failUnlessSuccessOr, maybePtr)
 
 ##include "windows_cconv.h"
@@ -477,9 +477,9 @@ regSetValue :: HKEY -> String -> String -> IO ()
 regSetValue key subkey value =
   withForeignPtr key $ \ p_key ->
   withTString subkey $ \ c_subkey ->
-  withTStringLen value $ \ (c_value, value_len) ->
+  withTString value $ \ c_value ->
   failUnlessSuccess "RegSetValue" $
-    c_RegSetValue p_key c_subkey rEG_SZ c_value value_len
+    c_RegSetValue p_key c_subkey rEG_SZ c_value 0 -- cbData is ignored, value needs to be null terminated.
 foreign import WINDOWS_CCONV unsafe "windows.h RegSetValueW"
   c_RegSetValue :: PKEY -> LPCTSTR -> DWORD -> LPCTSTR -> Int -> IO ErrCode
 



More information about the ghc-commits mailing list