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

Nit: fix range check in vcdecoder.cc #82

Open
maksverver opened this issue Jun 15, 2019 · 0 comments
Open

Nit: fix range check in vcdecoder.cc #82

maksverver opened this issue Jun 15, 2019 · 0 comments

Comments

@maksverver
Copy link

In vcdecoder.cc, there is a check to see if the copy address falls within the decoded buffer:

if ((decoded_address < 0) || (decoded_address > here_address)) {

Here, the expression (decoded_address > here_address) should be replaced by (decoded_address >= here_address). Otherwise, if decoded_address == here_address, you'll go into an infinite loop here:

open-vcdiff/src/vcdecoder.cc

Lines 1221 to 1228 in 868f459

while (size > (target_bytes_decoded - address)) {
// Recursive copy that extends into the yet-to-be-copied target data
const size_t partial_copy_size = target_bytes_decoded - address;
CopyBytes(&target_segment_ptr[address], partial_copy_size);
target_bytes_decoded += partial_copy_size;
address += partial_copy_size;
size -= partial_copy_size;
}

This isn't a problem in practice, because VCDiffAddressCache already validates the returned address (correctly, this time):

} else if (decoded_address >= here_address) {

So the check in vcdecoder.cc should be unnecessary. Still, if it's kept, it should be correct.

@maksverver maksverver changed the title Nit: fix in Nit: fix range check in vcdecoder.cc Jun 15, 2019
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

1 participant