udhcpc: make sure we do not overflow poll timeout
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 17 Feb 2017 18:20:32 +0000 (19:20 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 17 Feb 2017 18:20:32 +0000 (19:20 +0100)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
networking/udhcp/d6_dhcpc.c
networking/udhcp/dhcpc.c

index 067d351159eb204605c36dc34667419bed67a57c..bea589d71127c51472e9c38679369fee1bb8b22f 100644 (file)
@@ -1085,7 +1085,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
                if (tv > 0) {
                        log1("waiting on select %u seconds", tv);
                        timestamp_before_wait = (unsigned)monotonic_sec();
-                       retval = poll(pfds, 2, tv * 1000);
+                       retval = poll(pfds, 2, tv < INT_MAX/1000 ? tv * 1000 : INT_MAX);
                        if (retval < 0) {
                                /* EINTR? A signal was caught, don't panic */
                                if (errno == EINTR) {
index 8f7f59e0814b27d5cc6cd114e5952d27c04222ad..881512cf37d1fe6dbc2c3433c66cb415aae8911e 100644 (file)
@@ -1453,7 +1453,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
                if (tv > 0) {
                        log1("waiting on select %u seconds", tv);
                        timestamp_before_wait = (unsigned)monotonic_sec();
-                       retval = poll(pfds, 2, tv * 1000);
+                       retval = poll(pfds, 2, tv < INT_MAX/1000 ? tv * 1000 : INT_MAX);
                        if (retval < 0) {
                                /* EINTR? A signal was caught, don't panic */
                                if (errno == EINTR) {