rameshsharma
PDF encryption RuntimeError: integer out of range converting 4294967295 from a 8-byte signed type to a 4-byte signed type
Any one has encountered error like below for a pdf encryption:-
(exit) an exception was raised:
2020-11-02T23:16:20.453666662Z ** (RuntimeError) integer out of range converting 4294967295 from a 8-byte signed type to a 4-byte signed type
2020-11-02T23:16:20.453669462Z
2020-11-02T23:16:20.453671862Z (my_future_now 4.0.0) lib/my_future_now/services/encrypt_pdf_service.ex:61: MyFutureNow.EncryptPdfService.encrypt_pdf!/3
2020-11-02T23:16:20.453674663Z (my_future_now 4.0.0) lib/my_future_now/services/encrypt_pdf_service.ex:20: MyFutureNow.EncryptPdfService.encrypt_and_write_file!/2
2020-11-02T23:16:20.453677463Z (my_future_now 4.0.0) lib/my_future_now_web/email/loa_email.ex:90: MyFutureNowWeb.LOAEmail.employer_encrypted_loa_parts/1
2020-11-02T23:16:20.453680163Z (my_future_now 4.0.0) lib/my_future_now_web/email/loa_email.ex:353: MyFutureNowWeb.LOAEmail.loa_email_to_employer/2
Most Liked
kokolegorille
You should describe what You are doing, with which tools… like this it’s hard to have any idea.
rameshsharma
def encrypt_and_upload!(%Document{} = orig_document, opts \\ []) do
password = SecureRandom.urlsafe_base64(8)
orig_document
|> download_and_write_file!
|> encrypt_pdf!(password, opts)
|> upload_new!(password, orig_document)
end
def encrypt_and_write_file!(%Document{} = document, opts \\ []) do
path = download_and_write_file!(document)
password = SecureRandom.urlsafe_base64(8)
enc_path = encrypt_pdf!(path, password, opts)
{enc_path, password}
end
al2o3cr
RuntimeError is what raise produces; based on the stacktrace I’d guess {err, _} -> ... is on line 61.
qpdf is returning that message from deep in a utility function, unfortunately:
al2o3cr
This post is the first time I’ve ever seen qpdf, so I can’t really say what the problem is.
Skimming the changelog on that repo doesn’t show any obvious “fix this exact bug” entries since 9.1.1, but it likely wouldn’t hurt to upgrade.
The next lead I’d recommend you follow is that value 4294967295 - where does it appear in the input? Does qpdf give a different error for a different input file?
Edit to add: 4294967295 is 0xFFFF_FFFF, which is what you’d get if code mistakenly interpreted a 4-byte signed -1 as a 4-byte unsigned value - not sure if that’s significant.







