{"action":"created","issue":{"url":"https://api.github.com/repos/krzyzanowskim/ObjectivePGP/issues/29","labels_url":"https://api.github.com/repos/krzyzanowskim/ObjectivePGP/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/krzyzanowskim/ObjectivePGP/issues/29/comments","events_url":"https://api.github.com/repos/krzyzanowskim/ObjectivePGP/issues/29/events","html_url":"https://github.com/krzyzanowskim/ObjectivePGP/issues/29","id":113781493,"number":29,"title":"Encryption error when file is larger then 8383 bytes and crash when trying to decrypt","user":{"login":"ghaarsma","id":4742514,"avatar_url":"https://avatars.githubusercontent.com/u/4742514?v=3","gravatar_id":"","url":"https://api.github.com/users/ghaarsma","html_url":"https://github.com/ghaarsma","followers_url":"https://api.github.com/users/ghaarsma/followers","following_url":"https://api.github.com/users/ghaarsma/following{/other_user}","gists_url":"https://api.github.com/users/ghaarsma/gists{/gist_id}","starred_url":"https://api.github.com/users/ghaarsma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ghaarsma/subscriptions","organizations_url":"https://api.github.com/users/ghaarsma/orgs","repos_url":"https://api.github.com/users/ghaarsma/repos","events_url":"https://api.github.com/users/ghaarsma/events{/privacy}","received_events_url":"https://api.github.com/users/ghaarsma/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-28T09:56:30Z","updated_at":"2015-11-10T10:06:00Z","closed_at":null,"body":"When trying to encrypt a file larger then 8383 bytes an incorrect new format (Five-Octet Lengths) packet length is written.\r\n\r\nIn \"PGPPacket.m\" on lines 263:266 the single octet holding the value 255 is written twice.\r\n```objectivec\r\nUInt8 marker = 255;\r\n[data appendBytes:&marker length:1];\r\n\r\nbuf[0] = 0xff;\r\n```\r\nCommenting out lines 263/264 fixes the bug.\r\n\r\nWhen trying to decrypt an file with incorrect packet header, the GnuPG software strips the first 121 characters of the file away.\r\n\r\nWhen trying to decrypt an file with incorrect packet header with the ObjectivePGP library it crashes in \"PGPPacketFactory.m\" when executing line 54:\r\n```objectivec\r\nNSData *packetBodyData = [packetData subdataWithRange:(NSRange) {offset + packetHeaderData.length, finalBodyLength}];\r\n```\r\nBecause of the corrupt header, `definedBodyLength` is much to large. Should perhaps do a sanity check on `definedBodyLength` and report an error when it's larger then length of the packet data. Seems like there are multiple crash reports/issues related to this.\r\n\r\nGabe\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/krzyzanowskim/ObjectivePGP/issues/comments/155375928","html_url":"https://github.com/krzyzanowskim/ObjectivePGP/issues/29#issuecomment-155375928","issue_url":"https://api.github.com/repos/krzyzanowskim/ObjectivePGP/issues/29","id":155375928,"user":{"login":"krzyzanowskim","id":758033,"avatar_url":"https://avatars.githubusercontent.com/u/758033?v=3","gravatar_id":"","url":"https://api.github.com/users/krzyzanowskim","html_url":"https://github.com/krzyzanowskim","followers_url":"https://api.github.com/users/krzyzanowskim/followers","following_url":"https://api.github.com/users/krzyzanowskim/following{/other_user}","gists_url":"https://api.github.com/users/krzyzanowskim/gists{/gist_id}","starred_url":"https://api.github.com/users/krzyzanowskim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krzyzanowskim/subscriptions","organizations_url":"https://api.github.com/users/krzyzanowskim/orgs","repos_url":"https://api.github.com/users/krzyzanowskim/repos","events_url":"https://api.github.com/users/krzyzanowskim/events{/privacy}","received_events_url":"https://api.github.com/users/krzyzanowskim/received_events","type":"User","site_admin":false},"created_at":"2015-11-10T10:06:00Z","updated_at":"2015-11-10T10:06:00Z","body":"thx will review shortly"}}