summaryrefslogtreecommitdiffstats
path: root/mDNSResponder/mDNSCore/anonymous.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-09-19 08:52:21 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-09-20 11:23:32 +0200
commitf761b290f135957f47e1c9af71b4a81c76c32b48 (patch)
tree2b7d273db4ff2388867efec5ad432fa49cd4047e /mDNSResponder/mDNSCore/anonymous.c
parentmDNSResponder: Update to v576.30.4 (diff)
downloadrtems-libbsd-f761b290f135957f47e1c9af71b4a81c76c32b48.tar.bz2
mDNSResponder: Update to v625.41.2
The sources can be obtained via: https://opensource.apple.com/tarballs/mDNSResponder/mDNSResponder-625.41.2.tar.gz Update #3522.
Diffstat (limited to 'mDNSResponder/mDNSCore/anonymous.c')
-rw-r--r--mDNSResponder/mDNSCore/anonymous.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/mDNSResponder/mDNSCore/anonymous.c b/mDNSResponder/mDNSCore/anonymous.c
index 55a83175..779e4ea6 100644
--- a/mDNSResponder/mDNSCore/anonymous.c
+++ b/mDNSResponder/mDNSCore/anonymous.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 4 -*-
*
- * Copyright (c) 2012 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2012-2013 Apple Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,14 @@
#define ANON_NSEC3_ITERATIONS 1
+struct AnonInfoResourceRecord_struct
+{
+ ResourceRecord resrec;
+ RData rdatastorage;
+};
+
+typedef struct AnonInfoResourceRecord_struct AnonInfoResourceRecord;
+
mDNSlocal mDNSBool InitializeNSEC3Record(ResourceRecord *rr, const mDNSu8 *AnonData, int len, mDNSu32 salt)
{
const mDNSu8 *ptr;
@@ -118,9 +126,10 @@ mDNSlocal ResourceRecord *ConstructNSEC3Record(const domainname *service, const
mDNSlocal ResourceRecord *CopyNSEC3ResourceRecord(AnonymousInfo *si, const ResourceRecord *rr)
{
- int len;
+ AnonInfoResourceRecord *anonRR;
domainname *name;
- ResourceRecord *nsec3rr;
+ mDNSu32 neededLen;
+ mDNSu32 extraLen;
if (rr->rdlength < MCAST_NSEC3_RDLENGTH)
{
@@ -128,22 +137,26 @@ mDNSlocal ResourceRecord *CopyNSEC3ResourceRecord(AnonymousInfo *si, const Resou
return mDNSNULL;
}
// Allocate space for the name and the rdata along with the ResourceRecord
- len = DomainNameLength(rr->name);
- nsec3rr = mDNSPlatformMemAllocate(sizeof(ResourceRecord) + len + sizeof(RData));
- if (!nsec3rr)
+ neededLen = rr->rdlength + DomainNameLength(rr->name);
+ extraLen = (neededLen > sizeof(RDataBody)) ? (neededLen - sizeof(RDataBody)) : 0;
+ anonRR = (AnonInfoResourceRecord *)mDNSPlatformMemAllocate(sizeof(AnonInfoResourceRecord) + extraLen);
+ if (!anonRR)
return mDNSNULL;
- *nsec3rr = *rr;
- name = (domainname *)((mDNSu8 *)nsec3rr + sizeof(ResourceRecord));
- nsec3rr->name = (const domainname *)name;
+ anonRR->resrec = *rr;
+
+ anonRR->rdatastorage.MaxRDLength = rr->rdlength;
+ mDNSPlatformMemCopy(anonRR->rdatastorage.u.data, rr->rdata->u.data, rr->rdlength);
+
+ name = (domainname *)(anonRR->rdatastorage.u.data + rr->rdlength);
AssignDomainName(name, rr->name);
- nsec3rr->rdata = (RData *)((mDNSu8 *)nsec3rr->name + len);
- mDNSPlatformMemCopy(nsec3rr->rdata->u.data, rr->rdata->u.data, rr->rdlength);
+ anonRR->resrec.name = name;
+ anonRR->resrec.rdata = &anonRR->rdatastorage;
- si->nsec3RR = nsec3rr;
+ si->nsec3RR = (ResourceRecord *)anonRR;
- return nsec3rr;
+ return si->nsec3RR;
}
// When a service is started or a browse is started with the Anonymous data, we allocate a new random