Fix patch bug for zero-length copies and improve bad copy_cb() handling. #206
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix a bug which would make librsync patch hang for a corrupt delta containing a zero-length copy command. Patch will now fail returning RS_CORRUPT on encountering a zero length copy command.
Make rs_patch_s_copying() do assert() that copy_cb() didn't copy more data than requested so that debug builds highlight this API violation. Keep the backwards-compatible defensive behavior of only copying the amount requested for non-debug builds, but upgrade the (possibly disabled) trace about it to log warning. Fix the rs_trace() of "copy callback returned ..." to only output this trace if the copy_cb() failed.
Tidy rs_patch_s_literal() and rs_patch_s_copy() code for updating stats to make them consistent.
Add rs_warn() to trace.h to make it easier to log warnings.