Pack structures more tightly
This commit is contained in:
@@ -97,9 +97,11 @@ ISC_LANG_BEGINDECLS
|
||||
*/
|
||||
struct dns_name {
|
||||
unsigned int magic;
|
||||
unsigned char *ndata;
|
||||
unsigned int length;
|
||||
unsigned int labels;
|
||||
#pragma pack(push, 1)
|
||||
uint8_t length;
|
||||
uint8_t labels;
|
||||
#pragma pack(pop)
|
||||
#pragma pack(push, 2)
|
||||
struct dns_name_attrs {
|
||||
bool absolute : 1; /*%< Used by name.c */
|
||||
bool readonly : 1; /*%< Used by name.c */
|
||||
@@ -116,6 +118,8 @@ struct dns_name {
|
||||
bool update : 1; /*%< Used by client. */
|
||||
bool hasupdaterec : 1; /*%< Used by client. */
|
||||
} attributes;
|
||||
#pragma pack(pop)
|
||||
unsigned char *ndata;
|
||||
unsigned char *offsets;
|
||||
isc_buffer_t *buffer;
|
||||
ISC_LINK(dns_name_t) link;
|
||||
|
||||
@@ -109,17 +109,18 @@ ISC_LANG_BEGINDECLS
|
||||
* purpose the client desires.
|
||||
*/
|
||||
struct dns_rdata {
|
||||
unsigned char *data;
|
||||
unsigned int length;
|
||||
dns_rdataclass_t rdclass;
|
||||
dns_rdatatype_t type;
|
||||
unsigned int flags;
|
||||
uint16_t length;
|
||||
uint16_t flags;
|
||||
unsigned char *data;
|
||||
ISC_LINK(dns_rdata_t) link;
|
||||
};
|
||||
|
||||
// *data, len , rdclass, type, flags, link
|
||||
#define DNS_RDATA_INIT \
|
||||
{ \
|
||||
NULL, 0, 0, 0, 0, { (void *)(-1), (void *)(-1) } \
|
||||
0, 0, 0, 0, NULL, { (void *)(-1), (void *)(-1) } \
|
||||
}
|
||||
|
||||
#define DNS_RDATA_CHECKINITIALIZED
|
||||
|
||||
@@ -68,31 +68,27 @@ struct dns_slabheader_proof {
|
||||
};
|
||||
|
||||
struct dns_slabheader {
|
||||
/*%
|
||||
* Locked by the owning node's lock.
|
||||
*/
|
||||
uint32_t serial;
|
||||
dns_ttl_t ttl;
|
||||
dns_typepair_t type;
|
||||
atomic_uint_least16_t attributes;
|
||||
dns_trust_t trust;
|
||||
// 2
|
||||
_Atomic(uint16_t) attributes; // Locked by the owning node's lock.
|
||||
dns_trust_t trust; // Locked by the owning node's lock.
|
||||
// 4
|
||||
uint32_t serial; // Locked by the owning node's lock.
|
||||
dns_ttl_t ttl; // Locked by the owning node's lock.
|
||||
dns_typepair_t type; // Locked by the owning node's lock.
|
||||
|
||||
unsigned int heap_index;
|
||||
/*%<
|
||||
* Used for TTL-based cache cleaning.
|
||||
*/
|
||||
|
||||
isc_stdtime_t resign;
|
||||
_Atomic(uint16_t) count;
|
||||
unsigned int resign_lsb : 1;
|
||||
|
||||
atomic_uint_fast16_t count;
|
||||
isc_stdtime_t resign;
|
||||
unsigned int heap_index;
|
||||
/*%<
|
||||
* Monotonically increased every time this rdataset is bound so that
|
||||
* it is used as the base of the starting point in DNS responses
|
||||
* when the "cyclic" rrset-order is required.
|
||||
*/
|
||||
|
||||
atomic_uint_fast32_t last_refresh_fail_ts;
|
||||
isc_stdtime_t last_used;
|
||||
_Atomic(uint32_t) last_refresh_fail_ts;
|
||||
|
||||
dns_slabheader_proof_t *noqname;
|
||||
dns_slabheader_proof_t *closest;
|
||||
@@ -122,7 +118,6 @@ struct dns_slabheader {
|
||||
* this rdataset, if any.
|
||||
*/
|
||||
|
||||
isc_stdtime_t last_used;
|
||||
ISC_LINK(struct dns_slabheader) link;
|
||||
|
||||
/*%
|
||||
|
||||
+2
-3
@@ -107,8 +107,7 @@ dns_name_isvalid(const dns_name_t *name) {
|
||||
return (false);
|
||||
}
|
||||
|
||||
if (name->length > DNS_NAME_MAXWIRE ||
|
||||
name->labels > DNS_NAME_MAXLABELS)
|
||||
if (name->labels > DNS_NAME_MAXLABELS)
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
@@ -616,7 +615,7 @@ dns_name_getlabel(const dns_name_t *name, unsigned int n, dns_label_t *label) {
|
||||
SETUP_OFFSETS(name, offsets, odata);
|
||||
|
||||
label->base = &name->ndata[offsets[n]];
|
||||
if (n == name->labels - 1) {
|
||||
if (n == (unsigned int) name->labels - 1) {
|
||||
label->length = name->length - offsets[n];
|
||||
} else {
|
||||
label->length = offsets[n + 1] - offsets[n];
|
||||
|
||||
+1
-1
@@ -995,7 +995,7 @@ void
|
||||
dns_nsec3param_toprivate(dns_rdata_t *src, dns_rdata_t *target,
|
||||
dns_rdatatype_t privatetype, unsigned char *buf,
|
||||
size_t buflen) {
|
||||
REQUIRE(buflen >= src->length + 1);
|
||||
REQUIRE(buflen >= (unsigned int) src->length + 1);
|
||||
|
||||
REQUIRE(DNS_RDATA_INITIALIZED(target));
|
||||
|
||||
|
||||
+2
-2
@@ -17192,7 +17192,7 @@ getprivate:
|
||||
{
|
||||
next = ISC_LIST_NEXT(nsec3p, link);
|
||||
|
||||
if (nsec3p->length == rdata.length + 1 &&
|
||||
if (nsec3p->length == (unsigned int) rdata.length + 1 &&
|
||||
memcmp(rdata.data, nsec3p->data + 1,
|
||||
nsec3p->length - 1) == 0)
|
||||
{
|
||||
@@ -23773,7 +23773,7 @@ rss_post(void *arg) {
|
||||
dns_rdata_init(&rdata);
|
||||
dns_rdataset_current(&nrdataset, &rdata);
|
||||
|
||||
if (np->length == (rdata.length + 1) &&
|
||||
if (np->length == ((unsigned int) rdata.length + 1) &&
|
||||
memcmp(rdata.data, np->data + 1, np->length - 1) ==
|
||||
0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user