Check return value of gethostname() and truncate string.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23675 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
		| @@ -1259,7 +1259,14 @@ krb5_sname_to_principal (krb5_context context, | ||||
| 	return KRB5_SNAME_UNSUPP_NAMETYPE; | ||||
|     } | ||||
|     if(hostname == NULL) { | ||||
| 	gethostname(localhost, sizeof(localhost)); | ||||
| 	ret = gethostname(localhost, sizeof(localhost) - 1); | ||||
| 	if (ret != 0) { | ||||
| 	    ret = errno; | ||||
| 	    krb5_set_error_message(context, ret, | ||||
| 				   "Failed to get local hostname"); | ||||
| 	    return ret; | ||||
| 	}	     | ||||
| 	localhost[sizeof(localhost) - 1] = '\0'; | ||||
| 	hostname = localhost; | ||||
|     } | ||||
|     if(sname == NULL) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Love Hörnquist Åstrand
					Love Hörnquist Åstrand