Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot Reencode ASAR #2

Open
tscs37 opened this issue Apr 17, 2017 · 6 comments
Open

Cannot Reencode ASAR #2

tscs37 opened this issue Apr 17, 2017 · 6 comments
Labels

Comments

@tscs37
Copy link

tscs37 commented Apr 17, 2017

I've found that opening an ASAR file and attempting to reencode it directly leads to issues on the archive format.

When attempting to decode an ASAR generated with this library, I get the following error;

invalid character '\x00' looking for beginning of value

Electron doesn't want to open this file either and asar crashes with a stack error.

I suspect the header might be wrongly encoded.

@ghost
Copy link

ghost commented Apr 17, 2017

Are you able to attach a minimal ASAR file with which you are experiencing this bug?

@ghost ghost added the bug label Apr 17, 2017
@tscs37
Copy link
Author

tscs37 commented Apr 17, 2017

Sadly not, the only ASAR I've been able to reproduce this on is a 13MB large file.

However, I have found that the error changes from invalid character '\x00' looking for beginning of value
to invalid character '\'' looking for beginning of value when switching from copying strings to copying byte slices, additionally, it seems that these characters appear after the header in the ASAR.

It looks like the header size is not correctly encoded by some offset.

@tscs37
Copy link
Author

tscs37 commented Apr 17, 2017

The header_size section is as follows:

0400 0000 884A 0700 844A 0700 805A 0700

The header starts at 0x000010 and ends at 0x074A80, making it 0x74A70 or 477808 bytes long

According to header_size however it should end at 00075A80, making it 0x75A70 or 481905 bytes long

That means the encoder is miscalculating the header_size values by 4097 bytes.

@ghost ghost self-assigned this Apr 19, 2017
@yyq2013
Copy link

yyq2013 commented Jan 6, 2018

I have the same issue.
Finally change the code to work:
I copy it here and change some code
https://github.com/yyq2013/asar
Hope someone fix it.

@ghost
Copy link

ghost commented Jan 8, 2018

@yyq2013 Do you have an ASAR file that I can test this with?

@yyq2013
Copy link

yyq2013 commented Jan 9, 2018

@bontibon
Please change the zip to asar:
test.zip
out.zip

The first file test.asar is genereate by nodejs command "asar pack ...."
The second file out.asar is generated by the go asar lib from test.asar
code:

f:=test.asar
archive ,err := asar.Decode(f)
if err != nil {
glog.Error(err)
return
}
out:=out.asar
archive.EncodeTo(out)

And then:
Use go asar lib to read the out.asar you will get the error
Maybe not the same error out there, but there are the same type error(header size or other error ocurrs it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants