Subject: Re: gethostname and getdomainname
To: Christos Zoulas <christos@zoulas.com>
From: Ignatios Souvatzis <is@jocelyn.rhein.de>
List: tech-userlevel
Date: 11/18/1999 22:51:34
--0eh6TmSyL6TZE2Uz
Content-Type: text/plain; charset=us-ascii

On Thu, Nov 18, 1999 at 10:08:35PM +0100, Ignatios Souvatzis wrote:
> Here are my gethostname.c and getdomainname.c diffs.

Actually, here they are. I promise.

	-is

--0eh6TmSyL6TZE2Uz
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="getXXXname.diff"

Index: gen/gethostname.c
===================================================================
RCS file: /cvsroot/basesrc/lib/libc/gen/gethostname.c,v
retrieving revision 1.8
diff -u -r1.8 gethostname.c
--- gethostname.c	1999/09/20 04:39:01	1.8
+++ gethostname.c	1999/11/18 21:06:19
@@ -61,13 +61,20 @@
 {
 	int mib[2];
 	size_t size;
+	int olderrno;
 
 	_DIAGASSERT(name != NULL);
 
 	mib[0] = CTL_KERN;
 	mib[1] = KERN_HOSTNAME;
 	size = namelen;
-	if (sysctl(mib, 2, name, &size, NULL, 0) == -1)
+	olderrno = errno;
+	if (sysctl(mib, 2, name, &size, NULL, 0) == -1) {
+		if (errno == ENOMEM) {
+			errno = olderrno;
+			return (0);
+		}
 		return (-1);
+	}
 	return (0);
 }
Index: gen/getdomainname.c
===================================================================
RCS file: /cvsroot/basesrc/lib/libc/gen/getdomainname.c,v
retrieving revision 1.9
diff -u -r1.9 getdomainname.c
--- getdomainname.c	1999/09/20 04:39:00	1.9
+++ getdomainname.c	1999/11/18 21:06:19
@@ -61,13 +61,21 @@
 {
 	int mib[2];
 	size_t size;
+	int olderrno;
 
 	_DIAGASSERT(name != NULL);
 
 	mib[0] = CTL_KERN;
 	mib[1] = KERN_DOMAINNAME;
 	size = namelen;
-	if (sysctl(mib, 2, name, &size, NULL, 0) == -1)
+	olderrno = errno;
+	if (sysctl(mib, 2, name, &size, NULL, 0) == -1) {
+		if (errno == ENOMEM) {
+			errno = olderrno;
+			return (0);
+		}
 		return (-1);
+	}
+
 	return (0);
 }

--0eh6TmSyL6TZE2Uz--