git: 2871b8a185b2 - stable/14 - bspatch: use C23 overflow checking math now that it is available
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 25 Sep 2023 13:46:19 UTC
The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=2871b8a185b2c5b8de2d9f27301a7e523672b242 commit 2871b8a185b2c5b8de2d9f27301a7e523672b242 Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2023-09-05 16:35:31 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2023-09-25 13:45:06 +0000 bspatch: use C23 overflow checking math now that it is available Reviewed by: des Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D41771 (cherry picked from commit ee12faa062c04a49bf6fe4e6867bad8606e2413f) --- usr.bin/bsdiff/bspatch/bspatch.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/usr.bin/bsdiff/bspatch/bspatch.c b/usr.bin/bsdiff/bspatch/bspatch.c index a596ab1837dd..d7fabddabbfe 100644 --- a/usr.bin/bsdiff/bspatch/bspatch.c +++ b/usr.bin/bsdiff/bspatch/bspatch.c @@ -36,6 +36,7 @@ #include <fcntl.h> #include <libgen.h> #include <limits.h> +#include <stdckdint.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> @@ -64,15 +65,8 @@ add_off_t(off_t a, off_t b) { off_t result; -#if __GNUC__ >= 5 || \ - (defined(__has_builtin) && __has_builtin(__builtin_add_overflow)) - if (__builtin_add_overflow(a, b, &result)) + if (ckd_add(&result, a, b)) errx(1, "Corrupt patch"); -#else - if ((b > 0 && a > OFF_MAX - b) || (b < 0 && a < OFF_MIN - b)) - errx(1, "Corrupt patch"); - result = a + b; -#endif return result; }