From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kenji Arisawa Mime-Version: 1.0 (Apple Message framework v1278) Content-Type: multipart/alternative; boundary="Apple-Mail=_50DEFF62-EF7E-4857-B209-7EFBD84C6847" Date: Wed, 22 Aug 2012 21:09:34 +0900 In-Reply-To: <77e5af21864417917c398575fb84095d@rei2.9hal> To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> References: <77e5af21864417917c398575fb84095d@rei2.9hal> Message-Id: <2416E525-9386-437F-BD31-ED53D3AB1872@ar.aichi-u.ac.jp> Subject: Re: [9fans] dns Topicbox-Message-UUID: ad9cba0c-ead7-11e9-9d60-3106f5b1d025 --Apple-Mail=_50DEFF62-EF7E-4857-B209-7EFBD84C6847 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hello, On 2012/08/22, at 19:32, cinap_lenrek@gmx.de wrote: > the result check of that serveraddr() call should really be: >=20 > if (j < 0 || j > Maxdest) { > dnslog("serveraddrs() result %d out of range", = j); > abort(); > } > qp->curdest =3D &qp->dest[j]; what happens if j =3D=3D Maxdest ? note that j is index. I rather notice the foolowing code. /* use any addresses that we found */ for(trp =3D arp; trp && nd < Maxdest; trp =3D trp->next){ cur =3D &qp->dest[nd]; parseip(cur->a, trp->ip->name); /* * straddling servers can reject all nameservers if they = are all * inside, so be sure to list at least one outside ns at * the end of the ns list in /lib/ndb for `dom=3D'. */ if (ipisbm(cur->a) || cfg.straddle && !insideaddr(qp->dp->name) && = insidens(cur->a)) continue; cur->nx =3D 0; cur->s =3D trp->owner; cur->code =3D Rtimeout; nd++; } lock(&dnlock); rrfreelist(arp); unlock(&dnlock); return nd; returned value may be Maxdest.=20 This code is in function serveraddrs(), and the function must return = index. (must not be Maxdest) Kenji Arisawa --Apple-Mail=_50DEFF62-EF7E-4857-B209-7EFBD84C6847 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii cinap_lenrek@gmx.de = wrote:
the result = check of that serveraddr() call should really be:

if (j = < 0 || j > Maxdest) {
dnslog("serveraddrs() result %d = out of range", j);
abort();
= }
= = qp->curdest =3D = &qp->dest[j];

what = happens if j =3D=3D Maxdest ? note that j is = index.

I  rather notice the foolowing code.

/* use any addresses that we = found */
for(trp =3D arp; trp && = nd < Maxdest; trp =3D trp->next){
= cur =3D &qp->dest[nd];
= parseip(cur->a, trp->ip->name);
= /*
* straddling servers can = reject all nameservers if they are all
= * inside, so be sure to list at least one outside ns at
= * the end of the ns list in /lib/ndb for `dom=3D'.
= */
= if (ipisbm(cur->a) ||
  =  cfg.straddle && !insideaddr(qp->dp->name) && = insidens(cur->a))
= continue;
cur->nx =3D = 0;
= cur->s =3D trp->owner;
= cur->code =3D Rtimeout;
nd++;
= }
= lock(&dnlock);
rrfreelist(arp);
= unlock(&dnlock);
return = nd;

returned value may = be Maxdest. 
This code is in = function serveraddrs(), and the function must return index. (must = not be Maxdest)

Kenji = Arisawa



= --Apple-Mail=_50DEFF62-EF7E-4857-B209-7EFBD84C6847--