]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1387] free() conf_entry in ntp_intres removeentry().
authorDave Hart <hart@ntp.org>
Tue, 24 Nov 2009 14:51:38 +0000 (14:51 +0000)
committerDave Hart <hart@ntp.org>
Tue, 24 Nov 2009 14:51:38 +0000 (14:51 +0000)
[Bug 1392] intres retries duplicate assocations endlessly.

bk: 4b0bf2falaNCS43VNSA6FdySaJfxsw

ChangeLog
ntpd/ntp_intres.c
ntpd/ntp_peer.c

index 4cb3832b8f3e86df50f1dc6e80ad224b619bf798..2e96bac71e8c4966cca5c1a39635a47e91301aa1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 * [Bug 1387] Storage leak in ntp_intres (minor).
 * [Bug 1389] buffer overflow in refclock_oncore.c
 * [Bug 1391] .texi usage text from installed, not built binaries.
+* [Bug 1392] intres retries duplicate assocations endlessly.
 * Correct *-opts.h dependency so default 'get' action isn't used.
 (4.2.5p247-RC) 2009/11/20 Released by Harlan Stenn <stenn@ntp.org>
 * [Bug 1142] nodebug builds shed no light on -d, -D option failure.
index f6dcd341a594355ccabbe4175f4938f196ef6451..32ddff7494afee52674b4d543b0f4705ddfd79ae 100644 (file)
@@ -148,7 +148,8 @@ char *req_file;             /* name of the file with configuration info */
 
 
 static void    checkparent     (void);
-static void    removeentry     (struct conf_entry *);
+static struct conf_entry *
+               removeentry     (struct conf_entry *);
 static void    addentry        (char *, int, int, int, int, u_int,
                                   int, keyid_t, char *);
 static int     findhostaddr    (struct conf_entry *);
@@ -389,26 +390,30 @@ checkparent(void)
 /*
  * removeentry - we are done with an entry, remove it from the list
  */
-static void
+static struct conf_entry *
 removeentry(
        struct conf_entry *entry
        )
 {
        register struct conf_entry *ce;
+       struct conf_entry *next_ce;
 
        ce = confentries;
-       if (ce == entry) {
+       if (ce == entry)
                confentries = ce->ce_next;
-               return;
-       }
-
-       while (ce != NULL) {
-               if (ce->ce_next == entry) {
-                       ce->ce_next = entry->ce_next;
-                       return;
+       else
+               while (ce != NULL) {
+                       if (ce->ce_next == entry) {
+                               ce->ce_next = entry->ce_next;
+                               break;
+                       }
+                       ce = ce->ce_next;
                }
-               ce = ce->ce_next;
-       }
+
+       next_ce = entry->ce_next;
+       free(entry);
+
+       return next_ce;
 }
 
 
@@ -841,7 +846,7 @@ request(
                return 0;
        }
 #endif /* SYS_WINNT */
-    
+
 
        /*
         * Wait for a response.  A weakness of the mode 7 protocol used
@@ -987,6 +992,13 @@ request(
                        /* success */
                        return 1;
                
+                   case INFO_ERR_NODATA:
+                       /*
+                        * newpeer() refused duplicate association, no
+                        * point in retrying so call it success.
+                        */
+                       return 1;
+               
                    case INFO_ERR_IMPL:
                        msyslog(LOG_ERR,
                                "ntp_intres.request: implementation mismatch");
@@ -1002,11 +1014,6 @@ request(
                                "ntp_intres.request: format error");
                        return 0;
 
-                   case INFO_ERR_NODATA:
-                       msyslog(LOG_ERR,
-                               "ntp_intres.request: no data available");
-                       return 0;
-               
                    case INFO_ERR_AUTH:
                        msyslog(LOG_ERR,
                                "ntp_intres.request: permission denied");
@@ -1182,7 +1189,6 @@ doconfigure(
        )
 {
        register struct conf_entry *ce;
-       register struct conf_entry *ceremove;
 
 #ifdef DEBUG
                if (debug > 1)
@@ -1208,19 +1214,18 @@ doconfigure(
                                msyslog(LOG_ERR,
                                        "couldn't resolve `%s', giving up on it",
                                        ce->ce_name);
-                               ceremove = ce;
-                               ce = ceremove->ce_next;
-                               removeentry(ceremove);
+                               ce = removeentry(ce);
                                continue;
 #endif
-                       }
+                       } else if (!SOCK_UNSPEC(&ce->peer_store))
+                               msyslog(LOG_INFO,
+                                       "DNS %s -> %s", ce->ce_name,
+                                       stoa(&ce->peer_store));
                }
 
                if (!SOCK_UNSPEC(&ce->peer_store)) {
                        if (request(&ce->ce_config)) {
-                               ceremove = ce;
-                               ce = ceremove->ce_next;
-                               removeentry(ceremove);
+                               ce = removeentry(ce);
                                continue;
                        }
                        /* 
index 1a800bd2ba10164840e0afe443aa3eab3dbdb5df..8530089f4c8d1637e0031ce0d2f4ac8602981e33 100644 (file)
@@ -811,17 +811,12 @@ newpeer(
                peer->maxpoll = (u_char)max(maxpoll, NTP_MINPOLL);
        if (peer->minpoll > peer->maxpoll)
                peer->minpoll = peer->maxpoll;
-#ifdef DEBUG
-       if (debug > 2) {
-               if (peer->dstadr)
-                       printf("newpeer: using fd %d and our addr %s\n",
-                              peer->dstadr->fd,
-                                   stoa(&peer->dstadr->sin));
-               else
-                       printf("newpeer: local interface currently not bound\n");
-       }
-#endif
-       
+
+       if (peer->dstadr)
+               DPRINTF(3, ("newpeer: using fd %d and our addr %s\n",
+                           peer->dstadr->fd, stoa(&peer->dstadr->sin)));
+       else
+               DPRINTF(3, ("newpeer: local interface currently not bound\n")); 
 
        /*
         * Broadcast needs the socket enabled for broadcast