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

Unable to read attachment, no EOF found #2043

Closed
KingNoosh opened this issue Aug 23, 2017 · 8 comments
Closed

Unable to read attachment, no EOF found #2043

KingNoosh opened this issue Aug 23, 2017 · 8 comments

Comments

@KingNoosh
Copy link
Member

system info

Haraka Haraka.js — Version: 2.8.14
Node v6.11.2
OS Linux 498faf5af77a 4.9.41-moby #1 SMP Fri Aug 18 07:29:56 UTC 2017 x86_64 Linux
openssl

Expected behavior

Collect all the buffers of an attached zip file and Buffer.concat, then read its entries, then log byteSize and if it's encrypted.

Observed behavior

In attempting to collect all the buffers of a zip file and Buffer.concat, then read its entries. I keep getting an error that no End of File is found, this could either be the way Haraka gets the attachments, the way I'm trying to read them, or the library I'm trying to use which is yauzl.

Steps to reproduce

Create attachment hook to push chunk of data to array, on end Buffer.concat then pass into yauzl.fromBuffer.

Notes

I'm going to try piping instead but I'd like to just know why I'm facing this issue.

@smfreegard
Copy link
Collaborator

Without actually gisting your code, this is like asking how long a piece of string is. It should work, provided you're doing it right. The attachment stuff is tricky though.

@KingNoosh
Copy link
Member Author

@smfreegard
Copy link
Collaborator

Thought so - go and look at the attachment plugin, in particular the wait_for_attachment_hooks function. You need to prevent Haraka from continuing to process the message until your attachment hooks are finished, so that means creating a data_post hook that stores the callback which your attachment hooks run once all processing is complete.

Otherwise the connection could terminate before you're received all of the data and handled it.

@smfreegard
Copy link
Collaborator

In fact - if you're only interested in the filenames inside the zip file, why don't you just use the stock attachment plugin which already provides this (using bsdtar - which supports more archive formats than yauzl)??

@KingNoosh
Copy link
Member Author

I'm not, I want to know if the zip contains any encrypted files.

@smfreegard
Copy link
Collaborator

I take it you have an example zip then? Run it through bsdtar and I suspect you'll get an error returned saying that encryption isn't supported.

@KingNoosh
Copy link
Member Author

My issue here is that I can't save the file to the fs because of our clients, I feel that I should be able to do it with the stream or with the buffer I've made at the end.

I'm going to test right now that at the very least my buffer is good by trying to read a text file but if I need to save it to the fs, then I'll try with using bsdtar on the saved zip.

Sorry for the late reply.

@KingNoosh
Copy link
Member Author

I fixed this, was unrelated to Haraka.

I left a TODO which was flipping my is_enc var somewhere else.

Thank you!

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

No branches or pull requests

2 participants