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

Infinite loop for truncated signature or delta files. #32

Closed
paulharris opened this issue Jun 30, 2015 · 2 comments
Closed

Infinite loop for truncated signature or delta files. #32

paulharris opened this issue Jun 30, 2015 · 2 comments
Labels

Comments

@paulharris
Copy link

@paulharris paulharris commented Jun 30, 2015

This might be related to #29
I was investigating why delta files seem to have additional characters on the end when generating deltas of identical files...

With the current rdiff,

echo "Hello world" > input
rdiff signature input sig
rdiff delta sig input delt
rdiff patch input delt output
# all is fine
# time to hang the process, truncate the delta file
dd if=delt of=delt2 bs=1 count=1
rdiff patch input delt2 output
# HANG, infinite loop somewhere
# Note that when the delta file is big enough, THEN the problem is handled properly
dd if=delt of=delt2 bs=1 count=4
rdiff patch input delt2 output
librsync: ERROR: (librsync) patch job failed: unexpected end of input
librsync: ERROR: unexpected end of input
@sourcefrog sourcefrog added the bug label Jul 2, 2015
@dbaarda
Copy link
Member

@dbaarda dbaarda commented Oct 9, 2017

I had a quick look at this, checking with debug and tracing on and it gets stuck doing this;

rdiff: (rs_job_new) start patch job
rdiff: (rs_scoop_readahead) couldn't satisfy request for 4, scooping 0 bytes
rdiff: (rs_scoop_input) resized scoop buffer to 8 bytes from 0
rdiff: (rs_scoop_input) accepted 1 bytes from input to scoop
rdiff: (rs_infilebuf_fill) seen end of file on input
rdiff: (rs_scoop_readahead) data is present in the scoop and must be used
rdiff: (rs_scoop_input) accepted 0 bytes from input to scoop
rdiff: (rs_scoop_readahead) still have only 1 bytes in scoop
rdiff: (rs_scoop_readahead) data is present in the scoop and must be used
rdiff: (rs_scoop_input) accepted 0 bytes from input to scoop
rdiff: (rs_scoop_readahead) still have only 1 bytes in scoop
...

The problem is in rs_scoop_readahead() which doesn't check that the input is at eof before it completes a readahead. I'll try and put together a fix.

@dbaarda
Copy link
Member

@dbaarda dbaarda commented Oct 10, 2017

I've just submitted pull request #119 to fix this problem. I'll probably submit it soon unless someone encounters a problem with it.

Note this problem could also affect truncated signatures.

@dbaarda dbaarda changed the title Infinite loop when delta file is too small Infinite loop for truncated signature or delta files. Oct 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants