[Nagiosplug-devel] Flight 1.4.8, ready for boarding
Holger Weiss
holger at CIS.FU-Berlin.DE
Sat Mar 31 20:53:29 CEST 2007
* Thomas Guyot-Sionnest <Thomas at zango.com> [2007-03-30 09:16]:
> There's the two bugs with check_ntp. The segfault is caused by the fact that
> the check program don't get the jitter and so it tests a pointer that
> doesn't exist. I make a patch that fixes the segfault (Uploaded in the bug
> tracker)
Your patch should be committed in any case.
> but instead it returns a warning that it can't parse the jitter or something
> like that.
What is the exact message you get? The message "warning: unable to read
server jitter response" indicates that the server simply doesn't support
jitter control packets. However, with all servers I tried, the plugin
returns a WARNING state _without_ explaining the problem:
| $ ./check_ntp -H time.fu-berlin.de -j 2 -k 3
| NTP WARNING: Offset 0.05885159969 secs|offset=0.05885159969 jitter=0.001171
This WARNING is issued in jitter_request():
| if(! syncsource_found) *status = STATE_WARNING;
I'm not familiar with NTP and haven't tracked down whether the plugin
does something wrong while checking for the synchronization source; and
if not, whether it should really return a WARNING state here. If so,
the reason for the WARNING should certainly be mentioned in the plugin
output. For the moment, I committed patch which at least adds a line
explaining the WARNING to the verbose output.
> The other is a realloc error caught by glibc on my Ubuntu box. I have no
> idea what's wrong there (It's beyond my skills)...
The memcpy(3) following the realloc(3) call writes out of bounds as soon
as peer_offset is >0. I committed the following patch:
---------- 8< ----------------------------------------------------------
--- check_ntp.c 31 Mar 2007 17:35:08 -0000 1.17
+++ check_ntp.c 31 Mar 2007 18:40:46 -0000
@@ -506,6 +506,7 @@
ntp_control_message req;
double rval = 0.0, jitter = -1.0;
char *startofvalue=NULL, *nptr=NULL;
+ void *tmp;
/* Long-winded explanation:
* Getting the jitter requires a number of steps:
@@ -539,8 +540,10 @@
* we represent as a ntp_assoc_status_pair datatype.
*/
npeers+=(ntohs(req.count)/sizeof(ntp_assoc_status_pair));
- peers=(ntp_assoc_status_pair*)realloc(peers, sizeof(ntp_assoc_status_pair)*npeers);
- memcpy((void*)((ptrdiff_t)peers+peer_offset), (void*)req.data, sizeof(ntp_assoc_status_pair)*npeers);
+ if((tmp=realloc(peers, sizeof(ntp_assoc_status_pair)*npeers)) == NULL)
+ free(peers), die(STATE_UNKNOWN, "can not (re)allocate 'peers' buffer\n");
+ peers=tmp;
+ memcpy((void*)((ptrdiff_t)peers+peer_offset), (void*)req.data, ntohs(req.count));
peer_offset+=ntohs(req.count);
} while(req.op&REM_MORE);
---------- 8< ----------------------------------------------------------
Could you test whether this fixes the problem for you?
Holger
--
PGP fingerprint: F1F0 9071 8084 A426 DD59 9839 59D3 F3A1 B8B5 D3DE
More information about the Devel
mailing list