Page MenuHomeFreeBSD

bspatch: add sanity checks on sizes
ClosedPublic

Authored by emaste on Aug 23 2016, 11:26 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Apr 14, 3:16 AM
Unknown Object (File)
Tue, Apr 1, 9:54 PM
Unknown Object (File)
Mar 18 2025, 7:53 PM
Unknown Object (File)
Dec 8 2024, 6:31 PM
Unknown Object (File)
Nov 28 2024, 7:04 AM
Unknown Object (File)
Nov 18 2024, 10:12 AM
Unknown Object (File)
Nov 18 2024, 7:01 AM
Unknown Object (File)
Nov 17 2024, 6:12 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

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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
76–77 ↗(On Diff #19599)

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

123 ↗(On Diff #19599)

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

155 ↗(On Diff #19599)

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 ↗(On Diff #19679)

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

usr.bin/bsdiff/bspatch/bspatch.c
175 ↗(On Diff #19679)

Yes, a zero byte output file is legitimate.

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