From: Siddhesh Poyarekar <siddhesh@gotplt.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH 06/13] resolv: Add DNS packet parsing helpers geared towards wire format
Date: Fri, 19 Aug 2022 11:13:45 -0400 [thread overview]
Message-ID: <e6079988-c028-ba19-2aa1-11ddf3856487@gotplt.org> (raw)
In-Reply-To: <87wnb4z3cq.fsf@oldenburg.str.redhat.com>
On 2022-08-19 10:59, Florian Weimer wrote:
> * Siddhesh Poyarekar:
>
>>> +bool
>>> +__ns_rr_cursor_next (struct ns_rr_cursor *c, struct ns_rr_wire *rr)
>>> +{
>>> + rr->rdata = NULL;
>>> +
>>> + /* Extract the record owner name. */
>>> + int consumed = __ns_name_unpack (c->begin, c->end, c->current,
>>> + rr->rname, sizeof (rr->rname));
>>> + if (consumed < 0)
>>> + {
>>> + memset (rr, 0, sizeof (*rr));
>>> + __set_errno (EMSGSIZE);
>>> + return false;
>>> + }
>>> + c->current += consumed;
>>> +
>>> + /* Extract the metadata. */
>>> + struct
>>> + {
>>> + uint16_t rtype;
>>> + uint16_t rclass;
>>> + uint32_t ttl;
>>> + uint16_t rdlength;
>>> + } __attribute__ ((packed)) metadata;
>>> + _Static_assert (sizeof (metadata) == 10, "sizeof metadata");
>>> + if (c->end - c->current < sizeof (metadata))
>>> + {
>>> + memset (rr, 0, sizeof (*rr));
>>> + __set_errno (EMSGSIZE);
>>> + return false;
>>> + }
>>> + memcpy (&metadata, c->current, sizeof (metadata));
>>
>> Doesn't this go out of sync with the init above? The initialization
>> appears to put current just after rclass (with current += 4).
>
> Do you mean __ns_rr_cursor_init? The question section has a different
> entry layout than the other sections.
>
> Quoting RFC 1035:
>
> | 4.1.2. Question section format
> |
> | The question section is used to carry the "question" in most queries,
> | i.e., the parameters that define what is being asked. The section
> | contains QDCOUNT (usually 1) entries, each of the following format:
> |
> | 1 1 1 1 1 1
> | 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
> | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
> | | |
> | / QNAME /
> | / /
> | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
> | | QTYPE |
> | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
> | | QCLASS |
> | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
>
> Versus:
>
> | 4.1.3. Resource record format
> |
> | The answer, authority, and additional sections all share the same
> | format: a variable number of resource records, where the number of
> | records is specified in the corresponding count field in the header.
> | Each resource record has the following format:
> | 1 1 1 1 1 1
> | 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
> | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
> | | |
> | / /
> | / NAME /
> | | |
> | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
> | | TYPE |
> | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
> | | CLASS |
> | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
> | | TTL |
> | | |
> | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
> | | RDLENGTH |
> | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
> | / RDATA /
> | / /
> | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
>
> At least I hope this is what your question is about. 8-)
Indeed I mixed up the two. Let me resume review from there then.
Thanks,
Sid
next prev parent reply other threads:[~2022-08-19 15:13 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-10 9:30 [PATCH 00/13] nss_dns: Fix handling of non-host CNAMEs (bug 12154) Florian Weimer
2022-08-10 9:30 ` [PATCH 01/13] resolv: Add tst-resolv-byaddr for testing reverse lookup Florian Weimer
2022-08-18 15:26 ` Siddhesh Poyarekar
2022-08-10 9:30 ` [PATCH 02/13] resolv: Add tst-resolv-aliases Florian Weimer
2022-08-18 16:36 ` Siddhesh Poyarekar
2022-08-19 14:20 ` Florian Weimer
2022-08-19 14:27 ` Siddhesh Poyarekar
2022-08-19 14:54 ` Florian Weimer
2022-08-24 13:30 ` Florian Weimer
2022-08-10 9:30 ` [PATCH 03/13] resolv: Add internal __res_binary_hnok function Florian Weimer
2022-08-18 16:40 ` Siddhesh Poyarekar
2022-08-10 9:30 ` [PATCH 04/13] resolv: Add the __ns_samebinaryname function Florian Weimer
2022-08-18 16:46 ` Siddhesh Poyarekar
2022-08-10 9:30 ` [PATCH 05/13] resolv: Add internal __ns_name_length_uncompressed function Florian Weimer
2022-08-18 17:23 ` Siddhesh Poyarekar
2022-08-10 9:30 ` [PATCH 06/13] resolv: Add DNS packet parsing helpers geared towards wire format Florian Weimer
2022-08-18 18:57 ` Siddhesh Poyarekar
2022-08-19 14:59 ` Florian Weimer
2022-08-19 15:13 ` Siddhesh Poyarekar [this message]
2022-08-22 15:59 ` Siddhesh Poyarekar
2022-08-10 9:30 ` [PATCH 07/13] nss_dns: Split getanswer_ptr from getanswer_r Florian Weimer
2022-08-22 16:18 ` Siddhesh Poyarekar
2022-08-10 9:30 ` [PATCH 08/13] nss_dns: Rewrite _nss_dns_gethostbyaddr2_r and getanswer_ptr Florian Weimer
2022-08-22 21:59 ` Siddhesh Poyarekar
2022-08-10 9:30 ` [PATCH 09/13] nss_dns: Remove remnants of IPv6 address mapping Florian Weimer
2022-08-22 22:05 ` Siddhesh Poyarekar
2022-08-10 9:30 ` [PATCH 10/13] nss_dns: Rewrite getanswer_r to match getanswer_ptr (bug 12154, bug 29305) Florian Weimer
2022-08-22 22:20 ` Siddhesh Poyarekar
2022-08-10 9:31 ` [PATCH 11/13] nss_dns: In gaih_getanswer_slice, skip strange aliases (bug 12154) Florian Weimer
2022-08-23 12:23 ` Siddhesh Poyarekar
2022-08-10 9:31 ` [PATCH 12/13] resolv: Add new tst-resolv-invalid-cname Florian Weimer
2022-08-23 12:32 ` Siddhesh Poyarekar
2022-08-10 9:31 ` [PATCH 13/13] nss_dns: Rewrite _nss_dns_gethostbyname4_r using current interfaces Florian Weimer
2022-08-23 12:49 ` Siddhesh Poyarekar
2022-08-24 12:25 ` Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e6079988-c028-ba19-2aa1-11ddf3856487@gotplt.org \
--to=siddhesh@gotplt.org \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).