[823] forwarder setting with NetBSD/sparc

itojun at iijlab.net itojun at iijlab.net
Mon Feb 5 11:57:19 UTC 2001


>> 	solution would be to cleanup pointer from fwddata[], when a fwddata
>> 	item goes away.
>	Looks like a reasonable analysis.  Patch shortly.

	caveat: i'm still not sure if this is the complete solution.
	it seems not (i created a little patch, attached below, and
	the problem still persists for the guy who issued
	http://www.NetBSD.org/cgi-bin/query-pr-single.pl?number=12128).

itojun


? bin/named/ns_parser.h-
Index: bin/named/ns_config.c
===================================================================
RCS file: /cvsroot/basesrc/dist/bind/bin/named/ns_config.c,v
retrieving revision 1.4
diff -u -r1.4 ns_config.c
--- bin/named/ns_config.c	2001/01/27 07:21:58	1.4
+++ bin/named/ns_config.c	2001/02/05 11:56:57
@@ -2266,6 +2266,8 @@
 
 	for (i=0;i<fwddata_count; i++) {
 		fdp=fwddata[i];
+		if (!fdp)
+			continue;
 		if (memcmp(&fdp->fwdaddr.sin_addr,&address,sizeof(address))==0) {
 			fdp->ref_count++;
 			return fdp;
@@ -2462,10 +2464,15 @@
 void
 free_forwarders(struct fwdinfo *fwdtab) {
 	struct fwdinfo *ftp, *fnext;
+	int i;
 
 	for (ftp = fwdtab; ftp != NULL; ftp = fnext) {
 		fnext = ftp->next;
 		if (!--ftp->fwddata->ref_count) {
+			/* make sure to avoid dangling pointer in fwddata[] */
+			for (i = 0; i < fwddata_count; i++)
+				if (fwddata[i] == ftp->fwddata)
+					fwddata[i] = NULL;
 			memput(ftp->fwddata->ns, sizeof *ftp->fwddata->ns);
 			memput(ftp->fwddata->nsdata,
 					sizeof *ftp->fwddata->nsdata);


More information about the bind-workers mailing list