From: Ruben d'Arco Date: Wed, 27 Aug 2014 13:16:27 +0000 (+0200) Subject: Better way of replacing a few chars - thx cmouse! X-Git-Tag: auth-3.4.0-rc2~34^2~1^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F1683%2Fhead;p=thirdparty%2Fpdns.git Better way of replacing a few chars - thx cmouse! --- diff --git a/pdns/dnssecinfra.cc b/pdns/dnssecinfra.cc index 7cba28121a..29ef7dcb9c 100644 --- a/pdns/dnssecinfra.cc +++ b/pdns/dnssecinfra.cc @@ -543,10 +543,9 @@ string makeTSIGMessageFromTSIGPacket(const string& opacket, unsigned int tsigOff // Replace the message ID with the original message ID from the TSIG record. // This is needed for forwarded DNS Update as they get a new ID when forwarding (section 6.1 of RFC2136). The TSIG record stores the original ID and the // signature was created with the original ID, so we replace it here to get the originally signed message. - char lo = trc.d_origID & 0xFF; - char hi = trc.d_origID >> 8; - packet[1] = lo; - packet[0] = hi; + // If the message is not forwarded, we simply override it with the same id. + uint16_t origID = htons(trc.d_origID); + packet.replace(0, 2, (char*)&origID, 2); if(!previous.empty()) { uint16_t len = htons(previous.length());