Skip to content

Commit

Permalink
Fix bug in parsing signature subpacket lengths.
Browse files Browse the repository at this point in the history
  • Loading branch information
singpolyma committed Aug 10, 2013
1 parent bdc1636 commit 66e02f1
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Data/OpenPGP.hs
Expand Up @@ -1051,9 +1051,9 @@ instance BINARY_CLASS SignatureSubpacket where
get = do
len <- fmap fromIntegral (get :: Get Word8)
len <- case len of
_ | len > 190 && len < 255 -> do -- Two octet length
_ | len >= 192 && len < 255 -> do -- Two octet length
second <- fmap fromIntegral (get :: Get Word8)
return $ ((len - 192) `shiftR` 8) + second + 192
return $ ((len - 192) `shiftL` 8) + second + 192
255 -> -- Five octet length
fmap fromIntegral (get :: Get Word32)
_ -> -- One octet length, no furthur processing
Expand Down
Binary file added tests/data/3F5BBA0B0694BEB6000005-002.sig
Binary file not shown.
Binary file added tests/data/3F5BBA0B0694BEB6000017-002.sig
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/suite.hs
Expand Up @@ -145,6 +145,8 @@ tests =
testCase "uncompressed-ops-dsa.gpg" (testSerialization "uncompressed-ops-dsa.gpg"),
testCase "uncompressed-ops-dsa-sha384.txt.gpg" (testSerialization "uncompressed-ops-dsa-sha384.txt.gpg"),
testCase "uncompressed-ops-rsa.gpg" (testSerialization "uncompressed-ops-rsa.gpg"),
testCase "3F5BBA0B0694BEB6000005-002.sig" (testSerialization "3F5BBA0B0694BEB6000005-002.sig"),
testCase "3F5BBA0B0694BEB6000017-002.sig" (testSerialization "3F5BBA0B0694BEB6000017-002.sig"),
testProperty "MPI encode/decode" prop_MPI_serialization_loop,
testProperty "S2K encode/decode" prop_S2K_serialization_loop,
testProperty "SignatureSubpacket encode/decode" prop_SignatureSubpacket_serialization_loop
Expand Down

0 comments on commit 66e02f1

Please sign in to comment.