hostname bug

Kent Ibbetson bsd at kibbet.com
Mon Jan 19 16:24:13 PST 2004


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 at 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 ----




More information about the Submit mailing list