[5986] in Kerberos_V5_Development
PATCH: MIT krb5 1.2.2 and SIOCGIFCONF ioctl on Solaris
daemon@ATHENA.MIT.EDU (Nicolas Williams)
Wed May 9 13:57:17 2001
Date: Wed, 9 May 2001 13:53:29 -0400
From: Nicolas Williams <Nicolas.Williams@ubsw.com>
To: krbdev@mit.edu
Message-ID: <20010509135327.Y26763@sm2p1386swk.wdr.com>
Mail-Followup-To: krbdev@mit.edu
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
On Solaris ioctl() returns EINVAL if the ifconf buffer is not large
enough to store all the ifreq structures. The patch is rather simple.
The patch fixes two files:
- lib/krb5/os/localaddr.c (to check for EINVAL, double the buffer and
re-try the ioctl())
and
- lib/rpc/get_myaddress.c, to fix a typo/thinko
I note also that the initial call to malloc() the ifconf/ifreq buffer in
lib/krb5/os/localaddr.c is not checked for errors, nor is it free()ed if
there's an error. I did not fix that problem.
Nico
Index: PER-122.10/lib/rpc/get_myaddress.c
--- PER-122.10/lib/rpc/get_myaddress.c Wed, 14 Mar 2001 14:20:32 -0500 prondaja (MIT-krb5-src/c/b/5_get_myaddr 1.1 644)
+++ PER-122.11(w)/lib/rpc/get_myaddress.c Wed, 09 May 2001 11:02:35 -0400 willian (MIT-krb5-src/c/b/5_get_myaddr 1.2 644)
@@ -81,7 +81,7 @@
struct sockaddr_in *addr;
{
int s;
- char buf[256 * sizeof (struct ifconf)];
+ char buf[256 * sizeof (struct ifreq)];
struct ifconf ifc;
struct ifreq ifreq, *ifr;
int len;
Index: PER-122.10/lib/krb5/os/localaddr.c
--- PER-122.10/lib/krb5/os/localaddr.c Wed, 14 Mar 2001 14:20:32 -0500 prondaja (MIT-krb5-src/d/b/51_localaddr. 1.1 644)
+++ PER-122.11(w)/lib/krb5/os/localaddr.c Wed, 09 May 2001 11:17:39 -0400 willian (MIT-krb5-src/d/b/51_localaddr. 1.2 644)
@@ -334,6 +334,14 @@
code = ioctl (s, SIOCGIFCONF, (char *)&ifc);
if (code < 0) {
int retval = errno;
+ if (errno == EINVAL) {
+ est_if_count = est_if_count * 2;
+ buf = realloc(buf, est_ifreq_size * est_if_count);
+ if (buf) {
+ current_buf_size = est_ifreq_size * est_if_count;
+ goto ask_again;
+ }
+ }
closesocket (s);
return retval;
}