diff options
author | brian <brian@FreeBSD.org> | 1999-04-07 08:26:50 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1999-04-07 08:26:50 +0000 |
commit | 5a92170186174af48c0d17f5ac102cb6d86e3083 (patch) | |
tree | b32386f66508a569a16dbb8557a510fdc27c2fd7 /lib/libutil/realhostname.c | |
parent | 08ed5edfecf524101e8401c9b522617b56114ae4 (diff) | |
download | FreeBSD-src-5a92170186174af48c0d17f5ac102cb6d86e3083.zip FreeBSD-src-5a92170186174af48c0d17f5ac102cb6d86e3083.tar.gz |
Put parenthesis around sizeof args.
Allow for host names up to MAXHOSTNAMELEN - 1 in length.
Prompted by: bde
Diffstat (limited to 'lib/libutil/realhostname.c')
-rw-r--r-- | lib/libutil/realhostname.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/libutil/realhostname.c b/lib/libutil/realhostname.c index ff57011..240f929 100644 --- a/lib/libutil/realhostname.c +++ b/lib/libutil/realhostname.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id:$ + * $Id: realhostname.c,v 1.1 1999/04/06 23:02:35 brian Exp $ */ #include <sys/param.h> @@ -45,13 +45,13 @@ realhostname(char *host, size_t hsize, const struct in_addr *ip) struct hostent *hp; result = HOSTNAME_INVALIDADDR; - hp = gethostbyaddr((char *)ip, sizeof *ip, AF_INET); + hp = gethostbyaddr((char *)ip, sizeof(*ip), AF_INET); if (hp != NULL && strlen(hp->h_name) <= hsize) { - char lookup[MAXHOSTNAMELEN + 1]; + char lookup[MAXHOSTNAMELEN]; - strncpy(lookup, hp->h_name, sizeof lookup - 1); - lookup[sizeof lookup - 1] = '\0'; + strncpy(lookup, hp->h_name, sizeof(lookup) - 1); + lookup[sizeof(lookup) - 1] = '\0'; hp = gethostbyname(lookup); if (hp == NULL) result = HOSTNAME_INVALIDNAME; @@ -60,7 +60,7 @@ realhostname(char *host, size_t hsize, const struct in_addr *ip) result = HOSTNAME_INCORRECTNAME; break; } - if (!memcmp(*hp->h_addr_list, ip, sizeof *ip)) { + if (!memcmp(*hp->h_addr_list, ip, sizeof(*ip))) { strncpy(host, lookup, hsize); return HOSTNAME_FOUND; } |