]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
dhcp secs is a short
authorNicolas C <nchaigne@capgemini.fr>
Thu, 16 Jul 2015 09:50:50 +0000 (11:50 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 16 Jul 2015 12:10:10 +0000 (08:10 -0400)
Properly encode DHCP field "secs" (using htons instead of htonl).

Also I think in this case using "vp_short" is more correct than
"vp_integer" for a short (even though it still works with "vp_integer").

src/modules/proto_dhcp/dhcp.c

index 60c4053c17062e8f875f1ec686d2c4c84cd72ee0..6db0bfe06a003f79315b9c481aae12ef3d0a2946 100644 (file)
@@ -1367,6 +1367,7 @@ int fr_dhcp_encode(RADIUS_PACKET *packet)
        vp_cursor_t cursor;
        VALUE_PAIR *vp;
        uint32_t lvalue;
+       uint16_t        svalue;
        size_t dhcp_size;
        ssize_t len;
 #ifndef NDEBUG
@@ -1476,15 +1477,15 @@ int fr_dhcp_encode(RADIUS_PACKET *packet)
 
        /* DHCP-Number-of-Seconds */
        if ((vp = fr_pair_find_by_num(packet->vps, 261, DHCP_MAGIC_VENDOR, TAG_ANY))) {
-               lvalue = htonl(vp->vp_integer);
-               memcpy(p, &lvalue, 2);
+               svalue = htons(vp->vp_short);
+               memcpy(p, &svalue, 2);
        }
        p += 2;
 
        /* DHCP-Flags */
        if ((vp = fr_pair_find_by_num(packet->vps, 262, DHCP_MAGIC_VENDOR, TAG_ANY))) {
-               lvalue = htons(vp->vp_integer);
-               memcpy(p, &lvalue, 2);
+               svalue = htons(vp->vp_short);
+               memcpy(p, &svalue, 2);
        }
        p += 2;