core: dns cache - avoid bitshifting with more than the size
authorDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 27 Jul 2017 07:05:16 +0000 (09:05 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 27 Jul 2017 07:05:16 +0000 (09:05 +0200)
- avoid undefined behaviour as per C specs

src/core/dns_cache.c

index 7f3e338..e8bfd7f 100644 (file)
@@ -2344,7 +2344,7 @@ found:
 #endif
        /* i is the winner */
        *no=n; /* grp. start */
-       srv_mark_tried(tried, i); /* mark it */
+       if(i<8*sizeof(*tried)) srv_mark_tried(tried, i); /* mark it */
        return r_sums[i].rr;
 no_more_rrs:
        *no=n;