Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Tintel <stijn@linux-ipv6.be>2021-11-04 13:14:02 +0300
committerStijn Tintel <stijn@linux-ipv6.be>2021-11-04 14:03:25 +0300
commit123e976f3d012b310ac223a54b7ef5213107e33d (patch)
tree29efd101d31d8bd8930482e5130d8f6bcc9b3636 /uloop.c
parentbe3dc7223a6d75587e26f8b8d6d56920841e44b6 (diff)
uloop: restore return type of uloop_timeout_remaining
The uloop_timeout_remaining function is public and changing its return type breaks ABI. Change the return type back to int, and return INT_MIN or INT_MAX if the value returned by tv_diff would overflow integer. Fixes: be3dc7223a6d ("uloop: avoid integer overflow in tv_diff") Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be> Acked-by: Jo-Philipp Wich <jo@mein.io> Acked-by: John Crispin <john@phrozen.org>
Diffstat (limited to 'uloop.c')
-rw-r--r--uloop.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/uloop.c b/uloop.c
index 2972727..769b6c5 100644
--- a/uloop.c
+++ b/uloop.c
@@ -26,6 +26,7 @@
#include <string.h>
#include <fcntl.h>
#include <stdbool.h>
+#include <limits.h>
#include "uloop.h"
#include "utils.h"
@@ -317,8 +318,9 @@ int uloop_timeout_cancel(struct uloop_timeout *timeout)
return 0;
}
-int64_t uloop_timeout_remaining(struct uloop_timeout *timeout)
+int uloop_timeout_remaining(struct uloop_timeout *timeout)
{
+ int64_t td;
struct timeval now;
if (!timeout->pending)
@@ -326,7 +328,14 @@ int64_t uloop_timeout_remaining(struct uloop_timeout *timeout)
uloop_gettime(&now);
- return tv_diff(&timeout->time, &now);
+ td = tv_diff(&timeout->time, &now);
+
+ if (td > INT_MAX)
+ return INT_MAX;
+ else if (td < INT_MIN)
+ return INT_MIN;
+ else
+ return (int)td;
}
int uloop_process_add(struct uloop_process *p)