Check for possible negative diff timeout. Clamp it to 0 in that case.
authorclaudio <claudio@openbsd.org>
Thu, 25 Nov 2021 12:55:34 +0000 (12:55 +0000)
committerclaudio <claudio@openbsd.org>
Thu, 25 Nov 2021 12:55:34 +0000 (12:55 +0000)
poll with negative timeout noticed by job@
OK job@

usr.sbin/rpki-client/repo.c

index 5d8ecde..5c6aa5f 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: repo.c,v 1.12 2021/11/15 16:32:15 claudio Exp $ */
+/*     $OpenBSD: repo.c,v 1.13 2021/11/25 12:55:34 claudio Exp $ */
 /*
  * Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
  * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -1213,6 +1213,8 @@ repo_next_timeout(int timeout)
        SLIST_FOREACH(rp, &repos, entry) {
                if (repo_state(rp) == REPO_LOADING) {
                        int diff = rp->alarm - now;
+                       if (diff < 0)
+                               diff = 0;
                        diff *= 1000;
                        if (timeout == INFTIM || diff < timeout)
                                timeout = diff;