8000 Integer overflow bug in fastfilereader and offset parameter to stream a file by mayanks · Pull Request #533 · eventmachine/eventmachine · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Integer overflow bug in fastfilereader and offset parameter to stream a file #533

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

m
8000
ayanks
Copy link
@mayanks mayanks commented Sep 18, 2014

Nothing too fancy. Just had a requirement to stream a file from a certain offset (in case the file was not streamed completely last time). So went ahead and added this feature in the eventmachine.

Please accept this pull request if you feel it is a good feature to have.

@mayanks mayanks changed the title offset parameter to stream a file Integer overflow bug in fastfilereader and offset parameter to stream a file Sep 26, 2014
@mayanks
Copy link
Author
mayanks commented Sep 26, 2014

I also found that there was an integer overflow bug in fastfilereader module. The NUM2INT and INT2NUM were at fault. Changed them to NUM2LONG and LONG2NUM respectively.

@sodabrew
Copy link
Member

Looks reasonable - please rebase the PR, and squash to 2 commits: one for the int/long fixes, the other for the new offset feature.

ext/cmain.cpp Outdated
@@ -785,6 +785,8 @@ extern "C" int evma_send_file_data_to_connection (const unsigned long binding, c
return -1;
}

// seek to the offset first
lseek(Fd, offset, SEEK_SET);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind the tabs, not spaces.

@sodabrew
Copy link
Member

Hi - I noticed the added commits, but I don't think it came out as intended. You might have rebased locally, then done a 'git pull' and merged origin/master back into your local master before you pushed? The trick with a rebase is that you must force-push once you have the commits on your local branch organized as you wish, so that the origin matches local.

@mayanks
Copy link
Author
mayanks commented Jan 25, 2015

I should have commented that I messed this whole rebase business. I'll try and clean this up again. If I am not able to clean it, I'll submit a fresh pull request. I hope that should be fine.

Fixed bug in reading file greater than 2GB in size

converted INT to LONG to support >2GB file size

converted to NUM to LONG

sorry, my bad. used wrong macro

yet another overflow when adding start and offset

updated the function definition

converted to long to unsigned long
@mayanks
Copy link
Author
mayanks commented Jan 25, 2015

Hi Aaron, after some hiccups and doing multiple reverts, I finally managed to clean the commit tree (and learned some new git tricks).

Do let me know if this looks good. Thanks for your patience.

@sodabrew
Copy link
Member

Yes, this looks much better! From reading this again, I agree with the NUM2ULONG changes. Actually, I wonder if those should be NUM2SIZET http://rxr.whitequark.org/mri/source/include/ruby/ruby.h#672 for 64-bit files.

I am not comfortable with the offset parameter. The function evma_send_file_data_to_connection has a hardcoded 32KB buffer, so to send a large file you'd have to get the size, then iterate every 32KB until the end? That seems... less than ideal.

The best solution would be support for sendfile() per #215.

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

Successfully merging this pull request may close these issues.

2 participants
0