From 66e02f12198b4c9497d6193920ff80bc13551821 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Sat, 10 Aug 2013 13:34:54 -0500 Subject: Fix bug in parsing signature subpacket lengths. --- Data/OpenPGP.hs | 4 ++-- tests/data/3F5BBA0B0694BEB6000005-002.sig | Bin 0 -> 1089 bytes tests/data/3F5BBA0B0694BEB6000017-002.sig | Bin 0 -> 1089 bytes tests/suite.hs | 2 ++ 4 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 tests/data/3F5BBA0B0694BEB6000005-002.sig create mode 100644 tests/data/3F5BBA0B0694BEB6000017-002.sig diff --git a/Data/OpenPGP.hs b/Data/OpenPGP.hs index 3008fc2..7995d89 100644 --- a/Data/OpenPGP.hs +++ b/Data/OpenPGP.hs @@ -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 diff --git a/tests/data/3F5BBA0B0694BEB6000005-002.sig b/tests/data/3F5BBA0B0694BEB6000005-002.sig new file mode 100644 index 0000000..94055af Binary files /dev/null and b/tests/data/3F5BBA0B0694BEB6000005-002.sig differ diff --git a/tests/data/3F5BBA0B0694BEB6000017-002.sig b/tests/data/3F5BBA0B0694BEB6000017-002.sig new file mode 100644 index 0000000..b22f23b Binary files /dev/null and b/tests/data/3F5BBA0B0694BEB6000017-002.sig differ diff --git a/tests/suite.hs b/tests/suite.hs index 4bee6d6..cb4f4aa 100644 --- a/tests/suite.hs +++ b/tests/suite.hs @@ -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 -- cgit v1.2.3