]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
Read 48 bits of tsigtime, not 32
authorWillem Toorop <willem@nlnetlabs.nl>
Wed, 25 Sep 2013 14:04:41 +0000 (16:04 +0200)
committerWillem Toorop <willem@nlnetlabs.nl>
Wed, 25 Sep 2013 14:04:41 +0000 (16:04 +0200)
host2str.c

index 0a3c73b349b44a58013c63923260a444f21cbc06..798a049f4034b436d6aa250a51456a44caa861ac 100644 (file)
@@ -928,17 +928,20 @@ ldns_rdf2buffer_str_tsigtime(ldns_buffer *output,const  ldns_rdf *rdf)
        /* tsigtime is 48 bits network order unsigned integer */
        uint64_t tsigtime = 0;
        uint8_t *data = ldns_rdf_data(rdf);
+       uint64_t d0, d1, d2, d3, d4, d5;
 
-       if (ldns_rdf_size(rdf) != 6) {
+       if (ldns_rdf_size(rdf) < 6) {
                return LDNS_STATUS_WIRE_RDATA_ERR;
        }
+       d0 = data[0]; /* cast to uint64 for shift operations */
+       d1 = data[1];
+       d2 = data[2];
+       d3 = data[3];
+       d4 = data[4];
+       d5 = data[5];
+       tsigtime = (d0<<40) | (d1<<32) | (d2<<24) | (d3<<16) | (d4<<8) | d5;
 
-       tsigtime = ldns_read_uint16(data);
-       tsigtime *= 65536;
-       tsigtime += ldns_read_uint16(data+2);
-       tsigtime *= 65536;
-
-       ldns_buffer_printf(output, "%llu ", tsigtime);
+       ldns_buffer_printf(output, "%llu ", (long long)tsigtime);
 
        return ldns_buffer_status(output);
 }