time-util: add overflow checking to monotonic timestamp specifications
authorLennart Poettering <lennart@poettering.net>
Thu, 2 Feb 2017 17:35:00 +0000 (18:35 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 2 Feb 2017 19:12:32 +0000 (20:12 +0100)
src/basic/time-util.c

index fd86f1d..4ced1bc 100644 (file)
@@ -844,6 +844,8 @@ from_tm:
                 return -EINVAL;
 
 finish:
+        if (ret + plus < ret) /* overflow? */
+                return -EINVAL;
         ret += plus;
         if (ret > USEC_TIMESTAMP_FORMATTABLE_MAX)
                 return -EINVAL;