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

fix bug in original bsdiff program use of memcmp for string compare #8

Merged
merged 1 commit into from
Feb 14, 2020

Conversation

StefanKarpinski
Copy link
Member

@StefanKarpinski StefanKarpinski commented Feb 14, 2020

The original bsdiff program uses memcmp(old, new, min(length(old), length(new))) to lexicographically compare strings, but this is wrong in the case where they are equal up to the length of the shorter of the two strings. When memcmp returns zero, the tie should be broken by comparing the lengths of the strings, the shorter one coming first. This version makes slightly better patches, but the difference is rarely very significant. The patch format is unchanged, so patches produced by the Julia library can be consumed by the command and vice versa, but they no longer produce identical patches (the compression might have been different anyway).

@codecov
Copy link

codecov bot commented Feb 14, 2020

Codecov Report

Merging #8 into master will increase coverage by 0.08%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #8      +/-   ##
==========================================
+ Coverage   95.00%   95.08%   +0.08%     
==========================================
  Files           1        1              
  Lines         120      122       +2     
==========================================
+ Hits          114      116       +2     
  Misses          6        6              

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f08d2b7...73e4797. Read the comment docs.

@StefanKarpinski StefanKarpinski changed the title fix bug in original bsdiff program using memcmp for string compare fix bug in original bsdiff program use of memcmp for string compare Feb 14, 2020
@StefanKarpinski StefanKarpinski merged commit 6f84fcc into master Feb 14, 2020
@StefanKarpinski StefanKarpinski deleted the sk/diff-fix branch February 14, 2020 22:00
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.

1 participant