|
| 1 | +From a2e2ebea3641884dd436d938451d6c4db583ae28 Mon Sep 17 00:00:00 2001 |
| 2 | + |
| 3 | +Date: Thu, 19 Jun 2025 12:55:39 -0400 |
| 4 | +Subject: [PATCH] Address CVE-2025-47268 |
| 5 | +Upstream Patch Reference: https://github.com/iputils/iputils/pull/585/commits/b41e4a10ab1f749a9bd149c608213c9704c3147f.patch |
| 6 | + |
| 7 | +--- |
| 8 | + iputils_common.h | 3 +++ |
| 9 | + ping/ping_common.c | 22 +++++++++++++++++++--- |
| 10 | + 2 files changed, 22 insertions(+), 3 deletions(-) |
| 11 | + |
| 12 | +diff --git a/iputils_common.h b/iputils_common.h |
| 13 | +index 26e8f7c..d3070cb 100644 |
| 14 | +--- a/iputils_common.h |
| 15 | ++++ b/iputils_common.h |
| 16 | +@@ -10,6 +10,9 @@ |
| 17 | + !!__builtin_types_compatible_p(__typeof__(arr), \ |
| 18 | + __typeof__(&arr[0]))])) * 0) |
| 19 | + |
| 20 | ++/* 1000001 = 1000000 tv_sec + 1 tv_usec */ |
| 21 | ++#define TV_SEC_MAX_VAL (LONG_MAX/1000001) |
| 22 | ++ |
| 23 | + #ifdef __GNUC__ |
| 24 | + # define iputils_attribute_format(t, n, m) __attribute__((__format__ (t, n, m))) |
| 25 | + #else |
| 26 | +diff --git a/ping/ping_common.c b/ping/ping_common.c |
| 27 | +index ba46252..d68b21e 100644 |
| 28 | +--- a/ping/ping_common.c |
| 29 | ++++ b/ping/ping_common.c |
| 30 | +@@ -734,16 +734,32 @@ int gather_statistics(struct ping_rts *rts, uint8_t *icmph, int icmplen, |
| 31 | + |
| 32 | + restamp: |
| 33 | + tvsub(tv, &tmp_tv); |
| 34 | +- triptime = tv->tv_sec * 1000000 + tv->tv_usec; |
| 35 | +- if (triptime < 0) { |
| 36 | +- error(0, 0, _("Warning: time of day goes back (%ldus), taking countermeasures"), triptime); |
| 37 | ++ |
| 38 | ++ if (tv->tv_usec >= 1000000) { |
| 39 | ++ error(0, 0, _("Warning: invalid tv_usec %ld us"), tv->tv_usec); |
| 40 | ++ tv->tv_usec = 999999; |
| 41 | ++ } |
| 42 | ++ |
| 43 | ++ if (tv->tv_usec < 0) { |
| 44 | ++ error(0, 0, _("Warning: invalid tv_usec %ld us"), tv->tv_usec); |
| 45 | ++ tv->tv_usec = 0; |
| 46 | ++ } |
| 47 | ++ |
| 48 | ++ if (tv->tv_sec > TV_SEC_MAX_VAL) { |
| 49 | ++ error(0, 0, _("Warning: invalid tv_sec %ld s"), tv->tv_sec); |
| 50 | ++ triptime = 0; |
| 51 | ++ } else if (tv->tv_sec < 0) { |
| 52 | ++ error(0, 0, _("Warning: time of day goes back (%ld s), taking countermeasures"), tv->tv_sec); |
| 53 | + triptime = 0; |
| 54 | + if (!rts->opt_latency) { |
| 55 | + gettimeofday(tv, NULL); |
| 56 | + rts->opt_latency = 1; |
| 57 | + goto restamp; |
| 58 | + } |
| 59 | ++ } else { |
| 60 | ++ triptime = tv->tv_sec * 1000000 + tv->tv_usec; |
| 61 | + } |
| 62 | ++ |
| 63 | + if (!csfailed) { |
| 64 | + rts->tsum += triptime; |
| 65 | + rts->tsum2 += (double)((long long)triptime * (long long)triptime); |
| 66 | +-- |
| 67 | +2.34.1 |
| 68 | + |
0 commit comments