summaryrefslogtreecommitdiffstats
path: root/plugins/check_ntp_peer.c
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@users.sourceforge.net>2007-11-27 13:52:38 +0000
committerThomas Guyot-Sionnest <dermoth@users.sourceforge.net>2007-11-27 13:52:38 +0000
commit20470f273a16e4a19c3902b877226597e8a17d91 (patch)
treec6d85406637668e8c06683cfb20c6f7a2980742a /plugins/check_ntp_peer.c
parentef1f4e1e69338e5611a80b1110131b528377f624 (diff)
downloadmonitoring-plugins-20470f273a16e4a19c3902b877226597e8a17d91.tar.gz
Safer handling of te data pointer...
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/branches/dermoth_ntp_rework@1837 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_ntp_peer.c')
-rw-r--r--plugins/check_ntp_peer.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/plugins/check_ntp_peer.c b/plugins/check_ntp_peer.c
index a70e88ce..e0913add 100644
--- a/plugins/check_ntp_peer.c
+++ b/plugins/check_ntp_peer.c
@@ -218,7 +218,7 @@ setup_control_request(ntp_control_message *p, uint8_t opcode, uint16_t seq){
218 * the return value of the function. 218 * the return value of the function.
219 * status is pretty much useless as syncsource_found is a global variable 219 * status is pretty much useless as syncsource_found is a global variable
220 * used later in main to check is the server was synchronized. It works 220 * used later in main to check is the server was synchronized. It works
221 * so I left it alone, but it can be repurposed if needed */ 221 * so I left it alone */
222int ntp_request(const char *host, double *offset, int *offset_result, double *jitter, int *stratum){ 222int ntp_request(const char *host, double *offset, int *offset_result, double *jitter, int *stratum){
223 int conn=-1, i, npeers=0, num_candidates=0; 223 int conn=-1, i, npeers=0, num_candidates=0;
224 double tmp_offset = 0; 224 double tmp_offset = 0;
@@ -228,8 +228,7 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji
228 ntp_assoc_status_pair *peers=NULL; 228 ntp_assoc_status_pair *peers=NULL;
229 ntp_control_message req; 229 ntp_control_message req;
230 const char *getvar = "stratum,offset,jitter"; 230 const char *getvar = "stratum,offset,jitter";
231 char *data=""; 231 char *data=NULL, *value=NULL, *nptr=NULL;
232 char *value=NULL, *nptr=NULL;
233 void *tmp; 232 void *tmp;
234 233
235 status = STATE_OK; 234 status = STATE_OK;
@@ -303,7 +302,7 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji
303 /* If there's no sync.peer, query all candidates and use the best one */ 302 /* If there's no sync.peer, query all candidates and use the best one */
304 if (PEER_SEL(peers[i].status) >= min_peer_sel){ 303 if (PEER_SEL(peers[i].status) >= min_peer_sel){
305 if(verbose) printf("Getting offset, jitter and stratum for peer %.2x\n", ntohs(peers[i].assoc)); 304 if(verbose) printf("Getting offset, jitter and stratum for peer %.2x\n", ntohs(peers[i].assoc));
306 data = "\0"; 305 asprintf(&data, "");
307 do{ 306 do{
308 setup_control_request(&req, OP_READVAR, 2); 307 setup_control_request(&req, OP_READVAR, 2);
309 req.assoc = peers[i].assoc; 308 req.assoc = peers[i].assoc;