systemd/improve-overflow-checks.patch
Robert Milasan 294700e6ce - udev: re-add persistent network rules (bnc#809843).
add: 1026-re-add-persistent-net.patch
- rebase all patches, ensure that they apply properly.

OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=357
2013-03-20 10:29:34 +00:00

34 lines
1.2 KiB
Diff

From 3dd8ee8fa693597663b0338235becbb0b7a9520c Mon Sep 17 00:00:00 2001
From: Michal Sekletar <msekleta@redhat.com>
Date: Thu, 25 Oct 2012 16:16:17 +0200
Subject: [PATCH] util: fix possible integer overflows
---
src/shared/util.c | 6 ++++++
1 file changed, 6 insertions(+)
Index: systemd-195/src/shared/util.c
===================================================================
--- systemd-195.orig/src/shared/util.c
+++ systemd-195/src/shared/util.c
@@ -152,6 +152,9 @@ usec_t timespec_load(const struct timesp
ts->tv_nsec == (long) -1)
return (usec_t) -1;
+ if ((usec_t) ts->tv_sec > (UINT64_MAX - (ts->tv_nsec / NSEC_PER_USEC)) / USEC_PER_SEC)
+ return (usec_t) -1;
+
return
(usec_t) ts->tv_sec * USEC_PER_SEC +
(usec_t) ts->tv_nsec / NSEC_PER_USEC;
@@ -179,6 +182,9 @@ usec_t timeval_load(const struct timeval
tv->tv_usec == (suseconds_t) -1)
return (usec_t) -1;
+ if ((usec_t) tv->tv_sec > (UINT64_MAX - tv->tv_usec) / USEC_PER_SEC)
+ return (usec_t) -1;
+
return
(usec_t) tv->tv_sec * USEC_PER_SEC +
(usec_t) tv->tv_usec;