Date: Thu, 28 Feb 2002 15:07:44 +0900 From: Hajimu UMEMOTO <ume@mahoroba.org> To: Rob Braun <bbraun@FreeBSD.ORG> Cc: freebsd-net@FreeBSD.ORG Subject: Re: proposed changes to getnameinfo() implementation Message-ID: <ygewuwyqgun.wl@cheer.mahoroba.org> In-Reply-To: <200202272105.g1RL50J21344@lh.synack.net> References: <200202272105.g1RL50J21344@lh.synack.net>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi, >>>>> On Wed, 27 Feb 2002 13:04:59 -0800 >>>>> Rob Braun <bbraun@FreeBSD.ORG> said: bbraun> getnameinfo() takes a struct sockaddr pointer, and a length bbraun> parameter for the amount of memory pointed to by the struct bbraun> sockaddr pointer. No, the second parameter is not the amount of memory pointed to by the struct sockaddr pointer. It is the size of the struct sockaddr according to the address family. bbraun> The current FreeBSD implementation of getnameinfo() does bbraun> 2 problematic checks against the length parameter. First, bbraun> it makes sure the length parameter is equal to the length bbraun> specified in the passed in sockaddr structure. This is bbraun> problematic because the length parameter refers to the bbraun> amount of memory pointed to by the first parameter, and bbraun> the struct sockaddr sa_len field is used to specify the bbraun> size of the sockaddr structure, since there are different bbraun> types of sockaddr structures with different lengths. RFC2553 defines two types of struct sockaddr, one has sa_len and the other doesn't has it. Though we *BSD has sa_len, non-BSD doesn't have it. bbraun> I propose to change this exact match comparison to ensure bbraun> that the length passed in is at least what the sa_len bbraun> field is. This will allow a larger structure to be passed bbraun> in than the size of the sockaddr structure for the desired bbraun> protocol. It shouldn't. Though we actually doesn't need the second parameter of getnameinfo(), it is the alternative of the sa_len for the systems which don't have sa_len. To keep the portability of the application, we must set the size of the struct sockaddr according to the address family correctly. So, we should do such sanity checking. Furthermore, all of KAME delivered getnameinfo() including the version shipped by ISC do the checking. Changing to only FreeBSD will cause confusion. Sincerely, -- Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan ume@mahoroba.org ume@bisd.hitachi.co.jp ume@{,jp.}FreeBSD.org http://www.imasy.org/~ume/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ygewuwyqgun.wl>