DragonFly BSD
DragonFly submit List (threaded) for 2004-01
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

hostname bug


From: Kent Ibbetson <bsd@xxxxxxxxxx>
Date: Tue, 20 Jan 2004 10:22:16 +1000

Hey all,

Ewwps, I introduced a bug into hostname on the -i case, for when
the interface dosen't have a IP address attached. It will core dump
at sethostbyname, because hst (hostent struct) isn't filled in.

Attached patch fixes it.


Cheers,

-- 
Kent Ibbetson
bsd@xxxxxxxxxx
*** bin/hostname/hostname.c.orig	Tue Jan 20 09:57:24 2004
--- bin/hostname/hostname.c	Tue Jan 20 09:59:02 2004
***************
*** 280,285 ****
--- 280,289 ----
  			errx(1,"interface not found");
  		}
  
+ 		if (!hst) {
+ 			errx(1,"ip not found on interface");
+ 		}
+ 
  		if (h_errno == NETDB_SUCCESS) {
  			if (sethostname(hst->h_name, (int)strlen(hst->h_name)))
  				errx(1, "sethostname");
***************
*** 289,297 ****
  			errx(1,"gethostbyaddr");
  		}
  
- 		if (idx == 0) {
- 			errx(1,"interface not found");
- 		}
  	} else if (rflag) {
  		ret = inet_pton(AF_INET, srflag, &ia);
  		if (ret != 1) {
--- 293,298 ----


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]