diff options
author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2014-12-23 22:53:03 +0000 |
---|---|---|
committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2014-12-23 22:53:03 +0000 |
commit | eec2228f5545242471ebda48e26e79eb85156ee5 (patch) | |
tree | 2a94c6b6551f656a353dd6ab147668e43ecde45c /contrib/ntp/ntpd/ntp_control.c | |
parent | e9e69dbafd7921c68a66e87702c0583a2be20823 (diff) |
Notes
Diffstat (limited to 'contrib/ntp/ntpd/ntp_control.c')
-rw-r--r-- | contrib/ntp/ntpd/ntp_control.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/contrib/ntp/ntpd/ntp_control.c b/contrib/ntp/ntpd/ntp_control.c index 15f5856f2798..dbee89a0cdc5 100644 --- a/contrib/ntp/ntpd/ntp_control.c +++ b/contrib/ntp/ntpd/ntp_control.c @@ -24,6 +24,10 @@ #include <netinet/in.h> #include <arpa/inet.h> +#ifndef MIN +#define MIN(a, b) (((a) <= (b)) ? (a) : (b)) +#endif + /* * Structure to hold request procedure information */ @@ -893,6 +897,7 @@ ctl_putdata( ) { int overhead; + unsigned int currentlen; overhead = 0; if (!bin) { @@ -916,12 +921,22 @@ ctl_putdata( /* * Save room for trailing junk */ - if (dlen + overhead + datapt > dataend) { + while (dlen + overhead + datapt > dataend) { /* * Not enough room in this one, flush it out. */ + currentlen = MIN(dlen, dataend - datapt); + + memcpy(datapt, dp, currentlen); + + datapt += currentlen; + dp += currentlen; + dlen -= currentlen; + datalinelen += currentlen; + ctl_flushpkt(CTL_MORE); } + memmove((char *)datapt, dp, (unsigned)dlen); datapt += dlen; datalinelen += dlen; |