From: Dave Hart Date: Sat, 16 Apr 2011 18:14:13 +0000 (+0000) Subject: [Bug 1887] DNS fails on 4.2.7p153 using threads. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb8b1a3366dc785bf33879f4155a9259e9ee707f;p=thirdparty%2Fntp.git [Bug 1887] DNS fails on 4.2.7p153 using threads. bk: 4da9dc75fWyR7ZJMVo71w5TtVZiT5Q --- diff --git a/ChangeLog b/ChangeLog index 15fa2ef279..c601ebf4a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ +* [Bug 1887] DNS fails on 4.2.7p153 using threads. (4.2.7p153) 2011/04/16 Released by Harlan Stenn * A few more Coverity Scan cleanups. (4.2.7p152) 2011/04/15 Released by Harlan Stenn diff --git a/libntp/work_thread.c b/libntp/work_thread.c index 562eb04935..ea471c26fb 100644 --- a/libntp/work_thread.c +++ b/libntp/work_thread.c @@ -203,13 +203,15 @@ send_blocking_req_internal( ) { blocking_pipe_header * threadcopy; + size_t payload_octets; REQUIRE(hdr != NULL); REQUIRE(data != NULL); DEBUG_REQUIRE(BLOCKING_REQ_MAGIC == hdr->magic_sig); - if (sizeof(*hdr) < hdr->octets) + if (hdr->octets <= sizeof(*hdr)) return 1; /* failure */ + payload_octets = hdr->octets - sizeof(*hdr); ensure_workitems_empty_slot(c); if (NULL == c->thread_ref) { @@ -219,8 +221,7 @@ send_blocking_req_internal( threadcopy = emalloc(hdr->octets); memcpy(threadcopy, hdr, sizeof(*hdr)); - memcpy((char *)threadcopy + sizeof(*hdr), - data, hdr->octets - sizeof(*hdr)); + memcpy((char *)threadcopy + sizeof(*hdr), data, payload_octets); return queue_req_pointer(c, threadcopy); }