Modify

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#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 mLipok)

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 mLipok, 6 years ago

Description: modified (diff)

comment:2 by J-Paul Mesnage, 6 years ago

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

comment:3 by KaFu, 6 years ago

Because the current behavior crashes the whole script if the key does not exist. Instead it should return an error.

comment:4 by J-Paul Mesnage, 6 years ago

Milestone: 3.3.15.1
Owner: set to J-Paul Mesnage
Resolution: Fixed
Status: newclosed

Fixed by revision [12239] in version: 3.3.15.1

comment:5 by J-Paul Mesnage, 6 years ago

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

Modify Ticket

Action
as closed The owner will remain J-Paul Mesnage.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.