]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
extensions: time: Avoid undefined shift
authorPhil Sutter <phil@nwl.cc>
Thu, 5 Dec 2019 12:15:01 +0000 (13:15 +0100)
committerPhil Sutter <phil@nwl.cc>
Fri, 6 Dec 2019 11:12:08 +0000 (12:12 +0100)
Value 1 is signed by default and left-shifting by 31 is undefined for
those. Fix this by marking the value as unsigned.

Fixes: ad326ef9f734a ("Add the libxt_time iptables match")
extensions/libxt_time.c

index 5a8cc5de130313810276778684c80b02cd1b79f6..d001f5b7f448f75eb9917b4f71befd8dea42479d 100644 (file)
@@ -330,7 +330,7 @@ static void time_print_monthdays(uint32_t mask, bool human_readable)
 
        printf(" ");
        for (i = 1; i <= 31; ++i)
-               if (mask & (1 << i)) {
+               if (mask & (1u << i)) {
                        if (nbdays++ > 0)
                                printf(",");
                        printf("%u", i);