rameshsharma

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

kokolegorille

You should describe what You are doing, with which tools… like this it’s hard to have any idea.

rameshsharma

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

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

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.

Where Next?

Popular in Questions Top

dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Other popular topics Top

yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New

We're in Beta

About us Mission Statement