Modify ↓
Opened on Dec 13, 2019 at 2:45:37 PM
Closed on Jan 18, 2020 at 10:53:25 AM
Last modified on Jan 18, 2020 at 10:57:29 AM
#3744 closed Bug (Fixed)
_Crypt_DestroyKey() does not increment DLL handles
| Reported by: | KaFu | Owned by: | J-Paul Mesnage |
|---|---|---|---|
| Milestone: | 3.3.15.1 | Component: | Standard UDFs |
| Version: | 3.3.14.5 | Severity: | None |
| Keywords: | Cc: |
Description (last modified by )
The _Crypt_DestroyKey() contains a call to _Crypt_Shutdown(), decreasing DLL handles, but no call to _Crypt_Startup() to increase it in the first place.
#include <Crypt.au3> Local $Res = _Crypt_DestroyKey_Ex(1) ConsoleWrite($Res & @tab & @error & @TAB & @extended & @tab & _WinAPI_GetLastErrorMessage() & @crlf) Local $Res = _Crypt_DestroyKey(1) Func _Crypt_DestroyKey_Ex($hCryptKey) _Crypt_Startup() Local $aRet = DllCall(__Crypt_DllHandle(), "bool", "CryptDestroyKey", "handle", $hCryptKey) Local $iError = @error, $iExtended = @extended If Not $aRet[0] Then $iExtended = _WinAPI_GetLastError() _Crypt_Shutdown() If $iError Or Not $aRet[0] Then Return SetError($iError + 10, $iExtended, False) Else Return True EndIf EndFunc ;==>_Crypt_DestroyKey
Attachments (0)
Change History (5)
comment:1 by , on Dec 15, 2019 at 3:57:00 PM
| Description: | modified (diff) |
|---|
comment:3 by , on Jan 18, 2020 at 1:02:11 AM
Because the current behavior crashes the whole script if the key does not exist. Instead it should return an error.
comment:4 by , on Jan 18, 2020 at 10:53:25 AM
| Milestone: | → 3.3.15.1 |
|---|---|
| Owner: | set to |
| Resolution: | → Fixed |
| Status: | new → closed |
Fixed by revision [12239] in version: 3.3.15.1
comment:5 by , on Jan 18, 2020 at 10:57:29 AM
The solution is not to call Startup but just to return error
Func _Crypt_DestroyKey($hCryptKey) Local $aCall = DllCall(__Crypt_DllHandle(), "bool", "CryptDestroyKey", "handle", $hCryptKey) Local $iError = @error If $iError Or Not $aCall[0] Then Return SetError($iError + 10, _WinAPI_GetLastError(), False) Else _Crypt_Shutdown() Return True EndIf EndFunc ;==>_Crypt_DestroyKey
Note:
See TracTickets
for help on using tickets.

As The key must have been created with _Crypt_DeriveKey() I Don't understand the purpose of the request
Cheers