Subject: Re: freeaddrinfo(NUL)

From: Hideaki YOSHIFUJI (吉藤英明) <[email-masked]>
Date: Mon, 03 Jul 2000 19:16:34 +0900

Sorry for my too late response...

In article <[email-masked]> (at Thu, 27 Jan 2000 17:45:23 +0900), [email-masked] says:

> 	A question was raised about freeaddrinfo(NULL).
> 	Is it permitted, or should we just SEGV?

> 	My personal preference is to SEGV.  I can find no reason to allow it
> 	except NRL compatibilty.

I think freeaddrinfo(NULL) and freehostent(NULL) should also be 
allowed as free(NULL) is allowed; to avoid confusion.

If the returned buffer is bulkly malloc()ed, freeaddrinfo() 
will be:
void freeaddrinfo(struct addrinfo *ai){
    free(ai);
}

Similar question: How about getifaddrs()?

The getifaddrs(NULL) included in KAME kit doesn't raise an error, does it?
Why don't you have it raise a SEGV signal as you do in freeaddrinfo()?

void freeifaddrs(struct ifaddrs *ifp){
    if (!ifp) raise(SIG_SEGV);
    free(ifp);
}

I think freeifaddrs(NULL) should be allowed, too; again, to avoid confusion.

-- 
Hideaki YOSHIFUJI <[email-masked]>
Web Page: http://www.ecei.tohoku.ac.jp/%7Eyoshfuji/
PGP5i FP: F731 6599 5EB2 BBA7 1515  1323 1806 A96F 5700 6B25 
--------------------------------------------------------------------
IETF IPng Working Group Mailing List
IPng Home Page:                      http://playground.sun.com/ipng
FTP archive:                      ftp://playground.sun.com/pub/ipng
Direct all administrative requests to [email-masked]
--------------------------------------------------------------------

---

From: JINMEI Tatuya / 神明達哉<[email-masked]>
Date: Mon, 10 Jul 2000 01:07:19 +0900

This issue may not be suitable for this list, but I kept ccing for
the moment.

>>>>> On Mon, 03 Jul 2000 19:16:34 +0900, 
>>>>> Hideaki YOSHIFUJI <[email-masked]> said:

> The getifaddrs(NULL) included in KAME kit doesn't raise an error, does it?

No.

>     if (!ifp) raise(SIG_SEGV);

Just for clarfication: the current KAME's code of freeaddrinfo() does
not explicitly raise the SEGV signal against the NULL pointer. It
simply omits validation for the argument. SEGV is just a consequence of
this behavior. From this standpoint, there's no difference
between KAME's freeaddrinfo() and KAME's freeifaddrs(). The latter
also just assumes that the argument is a simple (valid) pointer, and
just frees the pointer without validation.

> I think freeifaddrs(NULL) should be allowed, too; again, to avoid confusion.

I don't have a strong opinion about particular behavior (including
whether the two functions should do the same reaction against the NULL
pointer). But, IMO, the most important thing is to document the
behavior, and, if possible, it would be better to standardize it.

					JINMEI, Tatuya
					Communication Platform Lab.
					Corporate R&D Center, Toshiba Corp.
					[email-masked]
--------------------------------------------------------------------
IETF IPng Working Group Mailing List
IPng Home Page:                      http://playground.sun.com/ipng
FTP archive:                      ftp://playground.sun.com/pub/ipng
Direct all administrative requests to [email-masked]
--------------------------------------------------------------------

---

From: JINMEI Tatuya / 神明達哉<[email-masked]>
Date: Mon, 10 Jul 2000 01:20:49 +0900

>>>>> On Mon, 10 Jul 2000 01:07:19 +0900, 
>>>>> JINMEI Tatuya <[email-masked]> said:

> This issue may not be suitable for this list, but I kept ccing for

ditto...

> No.

Ummm...I might have misunderstood...did you really mean
getifaddrs(NULL) here, or did you mistype "getifaddrs" instead of
"freeifaddrs"?

If you really meant the getifaddrs(NULL) case, the current KAME's
implementation would raise the SEGV signal. However, again, it's just
a consequence of the fact that the function omits validation of the
argument.

					JINMEI, Tatuya

---

From: Hideaki YOSHIFUJI <[email-masked]>
Date: Mon, 10 Jul 2000 11:00:56 +0900

> getifaddrs(NULL) here, or did you mistype "getifaddrs" instead of

Sorry, freeifaddrs().