Author: markj Date: Thu Jun 4 16:24:13 2020 New Revision: 361793 URL: https://svnweb.freebsd.org/changeset/base/361793
Log: dhclient: Fix a logic bug remove_protocol(). A logic bug in remove_protocol() meant that it would remove (leak) all structures in the list preceding the one intended for removal. PR: 245971 Submitted by: jo...@jodocus.org (original version) MFC after: 1 week Modified: head/sbin/dhclient/dispatch.c Modified: head/sbin/dhclient/dispatch.c ============================================================================== --- head/sbin/dhclient/dispatch.c Thu Jun 4 16:05:24 2020 (r361792) +++ head/sbin/dhclient/dispatch.c Thu Jun 4 16:24:13 2020 (r361793) @@ -474,13 +474,16 @@ add_protocol(const char *name, int fd, void (*handler) void remove_protocol(struct protocol *proto) { - struct protocol *p, *next; + struct protocol *p, *prev; - for (p = protocols; p; p = next) { - next = p->next; + for (p = protocols, prev = NULL; p != NULL; prev = p, p = p->next) { if (p == proto) { - protocols = p->next; + if (prev == NULL) + protocols = p->next; + else + prev->next = p->next; free(p); + break; } } } _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"