ueno / ruby-gpgme

a ruby interface to GnuPG Made Easy (GPGME).
GNU Lesser General Public License v2.1
232 stars 99 forks source link

KeyCommon.capability incorrectly reports every key has all possible capabilities #76

Closed garrettr closed 8 years ago

garrettr commented 8 years ago

In lib/gpgme/key_common.rb, capability returns a list of the key's capabilities based on the can_{certify, sign, encrypt, authenticate} values, which are copied from the underlying GPGME gpgme_subkey_t and can be either 0 or 1, indicating false or true as is the convention in C.

Unfortunately, the conditionals in capability look like this: caps << :encrypt if @can_encrypt.

Since @can_encrypt is either 0 or 1, this always returns true because every value in Ruby is "true" except for false and nil. As a result, capability incorrectly reports that every subkey has all capabilities.

A pull request that fixes this issue was filed in 2013, #29, but it appears to have been accidentally closed and was never merged. It has the correct fix and looks like it's still merge-able, so hopefully this should be exceptionally easy to resolve!

ageis commented 8 years ago

+1

ueno commented 8 years ago

oops, thanks for the reminder. it should be fixed as 97463efb98a884b1de908fca0a5ca316662a7943

garrettr commented 8 years ago

@ueno Do you know when this fix will make it into a release?