59 uint16_t pointer_target;
60 uint8_t pointer_target_buf[2];
62 size_t uncompressed_length = 0;
63 size_t compression_pos = 0;
65 unsigned int pointer_count = 0;
71 label_size = wire[*pos];
72 while (label_size > 0) {
74 while (label_size >= 192) {
75 if (compression_pos == 0) {
76 compression_pos = *pos + 2;
85 pointer_target_buf[0] = wire[*pos] & 63;
86 pointer_target_buf[1] = wire[*pos + 1];
87 pointer_target = ldns_read_uint16(pointer_target_buf);
89 if (pointer_target == 0) {
91 }
else if (pointer_target >= max) {
96 *pos = pointer_target;
97 label_size = wire[*pos];
104 if (*pos + 1 + label_size > max) {
112 tmp_dname[dname_pos] = label_size;
113 if (label_size > 0) {
120 memcpy(&tmp_dname[dname_pos], &wire[*pos], label_size);
121 uncompressed_length += label_size + 1;
122 dname_pos += label_size;
123 *pos = *pos + label_size;
126 label_size = wire[*pos];
130 if (compression_pos > 0) {
131 *pos = compression_pos;
140 tmp_dname[dname_pos] = 0;
144 (uint16_t) dname_pos, tmp_dname);
152 #define LDNS_STATUS_CHECK_RETURN(st) {if (st != LDNS_STATUS_OK) { return st; }}
153 #define LDNS_STATUS_CHECK_GOTO(st, label) {if (st != LDNS_STATUS_OK) { goto label; }}
159 size_t cur_rdf_length;
168 if (*pos + 2 > max) {
172 rd_length = ldns_read_uint16(&wire[*pos]);
175 if (*pos + rd_length > max) {
179 end = *pos + (size_t) rd_length;
191 switch (cur_rdf_type) {
224 cur_rdf_length = ((size_t) wire[*pos]) + 1;
227 cur_rdf_length = (size_t) ldns_read_uint16(&wire[*pos]) + 2;
232 cur_rdf_length = ((size_t) wire[*pos]) + 1;
250 cur_rdf_length = end - *pos;
255 if (cur_rdf_length > 0) {
256 if (cur_rdf_length + *pos > end) {
263 memcpy(data, &wire[*pos], cur_rdf_length);
265 cur_rdf =
ldns_rdf_new(cur_rdf_type, cur_rdf_length, data);
266 *pos = *pos + cur_rdf_length;
297 if (*pos + 4 > max) {
309 if (*pos + 4 > max) {
333 ldns_wire2pkt_hdr(
ldns_pkt *packet,
const uint8_t *wire,
size_t max,
size_t *pos)
365 ldns_buffer_limit(buffer));
381 status = ldns_wire2pkt_hdr(packet, wire, max, &pos);