Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

rlp tool fails to parse long hex string #5543

Closed
gumb0 opened this issue Apr 2, 2019 · 5 comments
Closed

rlp tool fails to parse long hex string #5543

gumb0 opened this issue Apr 2, 2019 · 5 comments

Comments

@gumb0
Copy link
Member

gumb0 commented Apr 2, 2019

> rlp/rlp 82abcd # short string is fine
"0xabcd"

> rlp/rlp  f884b8407098ad865b00a582051940cb9cf36836572411a47278783077011599ed5cd16b76f2635f4e234738f30813a89eb9137e3e3df5266e3a1f11df72ecf1145ccb9c01826964827634826970847f00000189736563703235366b31a103ca634cae0d49acb401d8a4c6b6fe8c55b70d115bf400769cc1400f3258cd31388375647082765f
terminate called after throwing an instance of 'boost::filesystem::filesystem_error'
  what():  boost::filesystem::status: File name too long: "f884b8407098ad865b00a582051940cb9cf36836572411a47278783077011599ed5cd16b76f2635f4e234738f30813a89eb9137e3e3df5266e3a1f11df72ecf1145ccb9c01826964827634826970847f00000189736563703235366b31a103ca634cae0d49acb401d8a4c6b6fe8c55b70d115bf400769cc1400f3258cd31388375647082765f"

I think boost::filesystem::is_regular_file throws unhandled exception in this case.

else if (boost::filesystem::is_regular_file(inputFile))

@twinstar26
Copy link
Contributor

Hi,
I would like to help and I have a couple of options that I could think of when this exception will be thrown:-

  1. We can manipulate the file name:- We can cut short the name of the file such that some of its parent directories form a string and the remaining will form second string. But it WILL NOT WORK since the above example proves the case wrong.
  2. We can substitute the string name by a unique identification mechanism (perhaps checksum) which is guaranteed to have fixed number of characters and also it's unique. Maybe we can maintain a dictionary so that we can retrieve results faster. (Never seen people use this.)

Also "boost:: filesystem::is_regular_file" throws "filesystem_error".
https://www.boost.org/doc/libs/1_69_0/libs/filesystem/doc/reference.html#is_regular_file

Also this exception "filesystem_error" is dependent on underlying OS API errors, at least "std:: filesystem::is_regular_file" will throw.
https://en.cppreference.com/w/cpp/filesystem/is_regular_file

@gumb0
Copy link
Member Author

gumb0 commented Apr 4, 2019

Hi @twinstar26, thank you for your interest, but it's not quite what we need I think.

rlp tool can take two kinds of input parameter: it's either a file name, then it reads the file and parses the contents; or it's a hexadecimal string, then it parses it directly.

The simple fix here could be to handle an exception thrown from boost::filesystem::is_regular_file call and consider the parameter to be a hex string in this case.

Does this make sense?

@twinstar26
Copy link
Contributor

Yeah okay. Guess I got too excited and mis-interpreted the issue. I will fix this soon.
Sorry for my misjudgement.

@twinstar26
Copy link
Contributor

This is as far as I got on my own.
https://github.com/twinstar26/aleth/blob/8a24e76f0a39c9a51503d7fbf206220a0225804d/rlp/main.cpp#L259-L273

I am stuck at this stage. (I am not that good at boost and this is just my start in opensource.)

@gumb0
Copy link
Member Author

gumb0 commented Apr 5, 2019

@twinstar26 Please create a pull request

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants