]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Document a tricky malloc() of dns_ctx in sntp
authorHarlan Stenn <stenn@ntp.org>
Tue, 23 Oct 2012 08:43:55 +0000 (08:43 +0000)
committerHarlan Stenn <stenn@ntp.org>
Tue, 23 Oct 2012 08:43:55 +0000 (08:43 +0000)
bk: 508658cbTttEaj-rcC5oMl534GVDmw

ChangeLog
sntp/main.c

index e72299fed4e68d209ea283bd9a147329b4db1cf3..6314bc8a5a3688f492a1b570275ba4f10e8c3f2b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+* Document a tricky malloc() of dns_ctx in sntp.
 (4.2.7p313) 2012/10/23 Released by Harlan Stenn <stenn@ntp.org>
 * [Bug 2291] sntp should report why it cannot open file.kod.
 * [Bug 2293] add support for SO_BINTIME, refine support for
index 9392106c81ba109cc07f6f88c38e4a1d3e16ff25..ae297f7ef4796ce9766018a4e1b66225f908f25e 100644 (file)
@@ -402,11 +402,11 @@ handle_lookup(
        hints.ai_protocol = IPPROTO_UDP;
 
        name_sz = 1 + strlen(name);
-       octets = sizeof(*ctx) + name_sz;
-       ctx = emalloc_zero(octets);
-       name_copy = (char *)(ctx + 1);
-       memcpy(name_copy, name, name_sz);
-       ctx->name = name_copy;
+       octets = sizeof(*ctx) + name_sz;        // Space for a ctx and the name
+       ctx = emalloc_zero(octets);             // ctx at ctx[0]
+       name_copy = (char *)(ctx + 1);          // Put the name at ctx[1]
+       memcpy(name_copy, name, name_sz);       // copy the name to ctx[1]
+       ctx->name = name_copy;                  // point to it...
        ctx->flags = flags;
        ctx->timeout = response_tv;