Modify

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#3744 closed Bug (Fixed)

_Crypt_DestroyKey() does not increment DLL handles

Reported by: KaFu Owned by: Jpm
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 Changed 5 years ago by mLipok

  • Description modified (diff)

comment:2 Changed 5 years ago by Jpm

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

comment:3 Changed 5 years ago by KaFu

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

comment:4 Changed 5 years ago by Jpm

  • Milestone set to 3.3.15.1
  • Owner set to Jpm
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [12239] in version: 3.3.15.1

comment:5 Changed 5 years ago by Jpm

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

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Jpm.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.