The intent here is to get the highest multiple of four smaller or equal
than i + 3. Instead of relying on integer division to get rid of the
remainder just to "undo" everything, simply clear the lowest two bits
(0b11 = 3) leaving multiples of four.

Index: ping.c
===================================================================
RCS file: /cvs/src/sbin/ping/ping.c,v
retrieving revision 1.218
diff -u -p -r1.218 ping.c
--- ping.c      22 Feb 2017 13:43:35 -0000      1.218
+++ ping.c      13 Jun 2017 17:29:19 -0000
@@ -1379,7 +1379,7 @@ pr_ipopt(int hlen, u_char *buf)
                            !memcmp(cp, old_rr, i) &&
                            !(options & F_FLOOD)) {
                                (void)printf("\t(same route)");
-                               i = ((i + 3) / 4) * 4;
+                               i = (i + 3) & ~0x3;
                                hlen -= i;
                                cp += i;
                                break;

Reply via email to