Page MenuHomeFreeBSD

ipfilter: Cast uintmax_t values to size_t when adding to a pointer.
ClosedPublic

Authored by jhb on Sep 27 2022, 5:41 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Feb 22, 2:25 PM
Unknown Object (File)
Fri, Feb 7, 12:50 AM
Unknown Object (File)
Jan 23 2025, 4:32 AM
Unknown Object (File)
Jan 22 2025, 5:55 PM
Unknown Object (File)
Nov 24 2024, 5:26 AM
Unknown Object (File)
Nov 7 2024, 10:12 AM
Unknown Object (File)
Nov 5 2024, 9:57 AM
Unknown Object (File)
Oct 1 2024, 5:32 AM

Details

Summary

GCC warns about the mismatched sizes on 32-bit platforms where
uintmax_t is larger in size than a pointer.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb requested review of this revision.Sep 27 2022, 5:41 PM
This revision is now accepted and ready to land.Sep 27 2022, 6:09 PM

assuming that you know that these can never be truncated, and that truncation won't cause a problem.

In D36753#834438, @imp wrote:

assuming that you know that these can never be truncated, and that truncation won't cause a problem.

If you have an offset bigger than size_t, you don't have a valid pointer (or you've wrapped around anyway). In practice arg2 are fairly small values that are offsets of fields in structures.