diff options
author | Ollivier Robert <roberto@FreeBSD.org> | 2013-12-04 21:33:17 +0000 |
---|---|---|
committer | Ollivier Robert <roberto@FreeBSD.org> | 2013-12-04 21:33:17 +0000 |
commit | 2b45e011ca352ce509bc83ae148230aeee0c7e0d (patch) | |
tree | a618007bb41d13153794a598e3d904ace2976324 /ntpd/refclock_hopfpci.c | |
parent | 9b5bd0a264b0a21eefac2b929b574c73bd601507 (diff) |
Virgin import of ntpd 4.2.6p5.vendor/ntp/4.2.6p5
When the series of commits is complete, things like
https://cert.litnet.lt/en/docs/ntp-distributed-reflection-dos-attacks
should be fixed.
PR: bin/148836 (except that we import a newer version)
Asked by: Too many
MFC after: 2 weeks
Notes
Notes:
svn path=/vendor/ntp/dist/; revision=258945
svn path=/vendor/ntp/4.2.6p5/; revision=258946; tag=vendor/ntp/4.2.6p5
Diffstat (limited to 'ntpd/refclock_hopfpci.c')
-rw-r--r-- | ntpd/refclock_hopfpci.c | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/ntpd/refclock_hopfpci.c b/ntpd/refclock_hopfpci.c index 81c186d168bd..284e3011c909 100644 --- a/ntpd/refclock_hopfpci.c +++ b/ntpd/refclock_hopfpci.c @@ -124,24 +124,17 @@ hopfpci_start( /* * Allocate and initialize unit structure */ - up = (struct hopfclock_unit *) emalloc(sizeof(struct hopfclock_unit)); - - if (!(up)) { - msyslog(LOG_ERR, "hopfPCIClock(%d) emalloc: %m",unit); -#ifdef DEBUG - printf("hopfPCIClock(%d) emalloc\n",unit); -#endif - return (0); - } - memset((char *)up, 0, sizeof(struct hopfclock_unit)); + up = emalloc(sizeof(*up)); + memset(up, 0, sizeof(*up)); #ifndef SYS_WINNT fd = open(DEVICE,O_RDWR); /* try to open hopf clock device */ #else - if (!OpenHopfDevice()){ - msyslog(LOG_ERR,"Start: %s unit: %d failed!",DEVICE,unit); + if (!OpenHopfDevice()) { + msyslog(LOG_ERR, "Start: %s unit: %d failed!", DEVICE, unit); + free(up); return (0); } #endif @@ -158,17 +151,12 @@ hopfpci_start( /* * Initialize miscellaneous peer variables */ - if (pp->unitptr!=0) { - memcpy((char *)&pp->refid, REFID, 4); - peer->precision = PRECISION; - pp->clockdesc = DESCRIPTION; - up->leap_status = 0; - up->unit = (short) unit; - return (1); - } - else { - return 0; - } + memcpy((char *)&pp->refid, REFID, 4); + peer->precision = PRECISION; + pp->clockdesc = DESCRIPTION; + up->leap_status = 0; + up->unit = (short) unit; + return (1); } @@ -187,6 +175,8 @@ hopfpci_shutdown( #else CloseHopfDevice(); #endif + if (NULL != peer->procptr->unitptr) + free(peer->procptr->unitptr); } @@ -221,9 +211,11 @@ hopfpci_poll( else pp->leap = LEAP_NOWARNING; - sprintf(pp->a_lastcode,"ST: %02X T: %02d:%02d:%02d.%03ld D: %02d.%02d.%04d", - m_time.wStatus, pp->hour, pp->minute, pp->second, - pp->nsec / 1000000, m_time.wDay, m_time.wMonth, m_time.wYear); + snprintf(pp->a_lastcode, sizeof(pp->a_lastcode), + "ST: %02X T: %02d:%02d:%02d.%03ld D: %02d.%02d.%04d", + m_time.wStatus, pp->hour, pp->minute, pp->second, + pp->nsec / 1000000, m_time.wDay, m_time.wMonth, + m_time.wYear); pp->lencode = (u_short)strlen(pp->a_lastcode); get_systime(&pp->lastrec); |