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>
#include <string.h>
#include <fcntl.h>
#include <stdbool.h>
+#include <limits.h>
#include "uloop.h"
#include "utils.h"
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)
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)
int uloop_timeout_add(struct uloop_timeout *timeout);
int uloop_timeout_set(struct uloop_timeout *timeout, int msecs);
int uloop_timeout_cancel(struct uloop_timeout *timeout);
-int64_t uloop_timeout_remaining(struct uloop_timeout *timeout);
+int uloop_timeout_remaining(struct uloop_timeout *timeout);
int uloop_process_add(struct uloop_process *p);
int uloop_process_delete(struct uloop_process *p);