SHA256
1
0
forked from pool/systemd
systemd/improve-overflow-checks.patch
Stephan Kulow 0b12bae943 Accepting request 160211 from Base:System
Please checkin also to openSUSE 12.3

- 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/request/show/160211
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=134
2013-03-22 11:08:23 +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;