Page MenuHomeFreeBSD

bspatch: add sanity checks on sizes
ClosedPublic

Authored by emaste on Aug 23 2016, 11:26 PM.
Tags
None
Referenced Files
F171257691: D7619.id19599.diff
Wed, Sep 9, 10:00 PM
F171249406: D7619.id19679.diff
Wed, Sep 9, 8:24 PM
Unknown Object (File)
Tue, Sep 8, 10:28 PM
Unknown Object (File)
Tue, Sep 8, 10:28 PM
Unknown Object (File)
Sat, Sep 5, 6:38 AM
Unknown Object (File)
Sat, Sep 5, 1:21 AM
Unknown Object (File)
Fri, Sep 4, 11:36 PM
Unknown Object (File)
Fri, Sep 4, 6:25 PM
Subscribers

Details

Summary

Note that on i386 this introduces a new 2GB limit, but this is not a concern in practice. Also avoid allocating an extra byte in the old and new file content buffers.

Based on the "NON-CRYPTANALYTIC ATTACKS AGAINST FREEBSD UPDATE COMPONENTS" gist.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

emaste retitled this revision from to bspatch: add sanity checks on sizes.
emaste updated this object.
emaste edited the test plan for this revision. (Show Details)
emaste added reviewers: allanjude, delphij, glebius.
emaste added a subscriber: cperciva.
usr.bin/bsdiff/bspatch/bspatch.c
88โ€“90

On i386 ssize_t is 4 bytes, so would truncate from offtin / lseek.

175

SSIZE_MAX introduces a 2G limit, but we already had an implicit 2G limit for proper operation based on the previous newsize type.

198โ€“199

Same 2G argument as above.

allanjude edited edge metadata.
This revision is now accepted and ready to land.Aug 25 2016, 4:57 PM
cem added a reviewer: cem.
cem added a subscriber: cem.

Changes seem fine to me. This code is really ugly, though.

usr.bin/bsdiff/bspatch/bspatch.c
175

The gist checks for newsize <= 0. Is zero a valid newsize?

usr.bin/bsdiff/bspatch/bspatch.c
175

Yes, a zero byte output file is legitimate.

kib added a reviewer: kib.
This revision was automatically updated to reflect the committed changes.