layeh / asar

Package asar reads and writes ASAR (Atom-Shell Archive) archives for Go (golang)
https://godoc.org/layeh.com/asar
Mozilla Public License 2.0
19 stars 12 forks source link

read corruption #3

Closed bradleypeabody closed 7 years ago

bradleypeabody commented 7 years ago

I have a test scenario where reading an ASAR file generated by electron-builder "succeeds" but produces corrupt output.

Go code:

func TestAsar(t *testing.T) {

    p := "/tmp/app.asar"
    f, err := os.Open(p)
    if err != nil {
        t.Fatal(err)
    }
    e, err := asar.Decode(f)
    if err != nil {
        t.Fatal(err)
    }

    homeE := e.Find("public", "home.html")

    r := homeE.Open()

    b, err := ioutil.ReadAll(r)
    if err != nil {
        t.Fatal(err)
    }

    log.Printf("b: %s", b)
}

Produces output like:

=== RUN   TestAsar
2017/06/26 16:43:43 b: tml>
<head>
.
.
.
</body>
</html>
<h
--- PASS: TestAsar (0.00s)

As you can see it has cut off 2 bytes at the start of the file and there are an extra 2 bytes at the end (I can't tell if those last two bytes are the 2 bytes of this same file or another html file).

The .asar file is 17mb and not something I want to post publicly but if you are able to take a look I can share with you on DropBox or other similar way.

ghost commented 7 years ago

@bradleypeabody my email address is on my github profile

bradleypeabody commented 7 years ago

Thanks Tim! You should have an email from DropBox with a link to the file.

ghost commented 7 years ago

@bradleypeabody Can you update and confirm that the latest commit fixes the issue?

go get -u layeh.com/asar
bradleypeabody commented 7 years ago

Works like a charm; thanks!