From: Simon Wilkinson Date: Sat, 2 Mar 2013 09:59:20 +0000 (+0000) Subject: auth: Don't overflow hostName array X-Git-Tag: upstream/1.8.0_pre1^2~1352 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=fed5dac9f25f7fbd74b6834ce6f087eaf31be2f2;p=packages%2Fo%2Fopenafs.git auth: Don't overflow hostName array afsconf_cell's hostName structure is a fixed length. Don't overflow it by writing whatever comes back from gethostbyaddr into it. Use strlcpy to catch an overflow, and if one occurs, just use "UNKNOWNHOST", rather than a truncated host name. Caught by coverity (#985906) Change-Id: Iaa927f3e4860d99166789e8dc4950a03ea2237e4 Reviewed-on: http://gerrit.openafs.org/9354 Reviewed-by: Derrick Brashear Tested-by: BuildBot Reviewed-by: Jeffrey Altman --- diff --git a/src/auth/writeconfig.c b/src/auth/writeconfig.c index 9d8d479ca..ad7c0b9fd 100644 --- a/src/auth/writeconfig.c +++ b/src/auth/writeconfig.c @@ -54,7 +54,12 @@ VerifyEntries(struct afsconf_cell *aci) if (!th) { strcpy(aci->hostName[i], "UNKNOWNHOST"); } else { - strcpy(aci->hostName[i], th->h_name); + if (strlcpy(aci->hostName[i], + th->h_name, + sizeof(aci->hostName[i])) + >= sizeof(aci->hostName[i])) { + strcpy(aci->hostName[i], "UNKNOWNHOST"); + } } } }