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

spiffs_object_read() read past end of file #237

Closed
apwise opened this issue Mar 24, 2019 · 2 comments
Closed

spiffs_object_read() read past end of file #237

apwise opened this issue Mar 24, 2019 · 2 comments

Comments

@apwise
Copy link

apwise commented Mar 24, 2019

In spiffs_object_read(), there's code to compute how much data can be read in each "chunk":

spiffs/src/spiffs_nucleus.c

Lines 2028 to 2033 in 1350deb

// all remaining data
u32_t len_to_read = offset + len - cur_offset;
// remaining data in page
len_to_read = MIN(len_to_read, SPIFFS_DATA_PAGE_SIZE(fs) - (cur_offset % SPIFFS_DATA_PAGE_SIZE(fs)));
// remaining data in file
len_to_read = MIN(len_to_read, fd->size);

surely the last of the tests above should be:
len_to_read = MIN(len_to_read, (fd->size - cur_offset));

as it should be testing how much data remains in the file to be read, not the total file size?

@pellepl
Copy link
Owner

pellepl commented Mar 24, 2019 via email

@pellepl pellepl closed this as completed in ec68ba8 Apr 4, 2019
@pellepl
Copy link
Owner

pellepl commented Apr 4, 2019

@apwise: thanks!

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