]> granicus.if.org Git - ipset/commitdiff
Fix invalid assignment to const void pointer
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Fri, 4 May 2012 20:06:50 +0000 (22:06 +0200)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Sun, 6 May 2012 20:10:14 +0000 (22:10 +0200)
gcc 4.7 and above ignore such assignments which leads to a broken
ipset binary (bug reported by Seblu).

lib/session.c

index 01a24137c5c6354cb4ba7ef9aa389831f292bdfd..6700ea18a1c08b01d37a2ed87c6751f510c5e01c 100644 (file)
@@ -1464,21 +1464,21 @@ rawdata2attr(struct ipset_session *session, struct nlmsghdr *nlh,
                return 1;
 
        switch (attr->type) {
-       case MNL_TYPE_NUL_STRING:
-               alen = strlen((const char *)d) + 1;
-               break;
        case MNL_TYPE_U32: {
                uint32_t value = htonl(*(const uint32_t *)d);
 
-               d = &value;
-               break;
+               mnl_attr_put(nlh, type | flags, alen, &value);
+               return 0;
        }
        case MNL_TYPE_U16: {
                uint16_t value = htons(*(const uint16_t *)d);
 
-               d = &value;
-               break;
+               mnl_attr_put(nlh, type | flags, alen, &value);
+               return 0;
        }
+       case MNL_TYPE_NUL_STRING:
+               alen = strlen((const char *)d) + 1;
+               break;
        default:
                break;
        }