From: Razvan Becheriu Date: Tue, 16 Mar 2021 10:11:17 +0000 (+0200) Subject: [#1680] inttotext should convert from network order X-Git-Tag: Kea-1.9.8~136 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97036e1acf6ecf0fa4a9812e854b0f16624f3564;p=thirdparty%2Fkea.git [#1680] inttotext should convert from network order --- diff --git a/src/lib/eval/token.cc b/src/lib/eval/token.cc index 4919b657a1..fded03d7cb 100644 --- a/src/lib/eval/token.cc +++ b/src/lib/eval/token.cc @@ -170,7 +170,8 @@ TokenInt16ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { } stringstream tmp; - tmp << *(reinterpret_cast(const_cast(op.data()))); + uint16_t value = *(reinterpret_cast(const_cast(op.data()))); + tmp << static_cast(ntohs(value)); op = tmp.str(); values.push(op); @@ -193,7 +194,8 @@ TokenInt32ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { } stringstream tmp; - tmp << *(reinterpret_cast(const_cast(op.data()))); + uint32_t value = *(reinterpret_cast(const_cast(op.data()))); + tmp << static_cast(ntohl(value)); op = tmp.str(); values.push(op); @@ -239,7 +241,8 @@ TokenUInt16ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { } stringstream tmp; - tmp << *(reinterpret_cast(const_cast(op.data()))); + uint16_t value = *(reinterpret_cast(const_cast(op.data()))); + tmp << ntohs(value); op = tmp.str(); values.push(op); @@ -262,7 +265,8 @@ TokenUInt32ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { } stringstream tmp; - tmp << *(reinterpret_cast(const_cast(op.data()))); + uint32_t value = *(reinterpret_cast(const_cast(op.data()))); + tmp << ntohl(value); op = tmp.str(); values.push(op);