diff options
| author | Ken Raeburn <raeburn@mit.edu> | 2000-12-06 09:46:49 +0000 |
|---|---|---|
| committer | Ken Raeburn <raeburn@mit.edu> | 2000-12-06 09:46:49 +0000 |
| commit | 80bbdfbc60404dd2edcd7c4512fd3bcd17073d00 (patch) | |
| tree | be49ee95dae90e7791fc455bfe7143a5cb9107c6 /src/util | |
| parent | c432d6933d55d1c04923fc8eacf17957db2b049f (diff) | |
| download | krb5-80bbdfbc60404dd2edcd7c4512fd3bcd17073d00.tar.gz krb5-80bbdfbc60404dd2edcd7c4512fd3bcd17073d00.tar.xz krb5-80bbdfbc60404dd2edcd7c4512fd3bcd17073d00.zip | |
make pty_make_sane_hostname take sockaddr* arg instead of sockaddr_in*
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@12883 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util')
| -rw-r--r-- | src/util/pty/ChangeLog | 6 | ||||
| -rw-r--r-- | src/util/pty/libpty.h | 2 | ||||
| -rw-r--r-- | src/util/pty/sane_hostname.c | 19 |
3 files changed, 20 insertions, 7 deletions
diff --git a/src/util/pty/ChangeLog b/src/util/pty/ChangeLog index a6e1b80f8..a7db011b0 100644 --- a/src/util/pty/ChangeLog +++ b/src/util/pty/ChangeLog @@ -1,3 +1,9 @@ +2000-12-06 Ken Raeburn <raeburn@mit.edu> + + * sane_hostname.c (pty_make_sane_hostname, do_ntoa): Pass address + as sockaddr pointer. + * libpty.h (pty_make_sane_hostname): Update prototype. + 2000-11-01 Ezra Peisach <epeisach@mit.edu> * configure.in: Quote macro use inside AC_CHECK_LIB. Change diff --git a/src/util/pty/libpty.h b/src/util/pty/libpty.h index 5fccf016d..5e1200bf5 100644 --- a/src/util/pty/libpty.h +++ b/src/util/pty/libpty.h @@ -49,7 +49,7 @@ long pty_cleanup(char *slave, int pid, int update_utmp); struct sockaddr_in; #endif -long pty_make_sane_hostname(struct sockaddr_in *, int, int, int, char **); +long pty_make_sane_hostname(struct sockaddr *, int, int, int, char **); #else /*__STDC__*/ long pty_init(); long pty_getpty(); diff --git a/src/util/pty/sane_hostname.c b/src/util/pty/sane_hostname.c index 43814df53..23955c06d 100644 --- a/src/util/pty/sane_hostname.c +++ b/src/util/pty/sane_hostname.c @@ -2,7 +2,7 @@ * pty_make_sane_hostname: Make a sane hostname from an IP address. * This returns allocated memory! * - * Copyright 1999 by the Massachusetts Institute of Technology. + * Copyright 1999,2000 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby @@ -25,17 +25,21 @@ #include <arpa/inet.h> static long -do_ntoa(struct sockaddr_in *addr, +do_ntoa(struct sockaddr *addr, size_t hostlen, char **out) { - strncpy(*out, inet_ntoa(addr->sin_addr), hostlen); + if (addr->sa_family == AF_INET) + strncpy(*out, inet_ntoa(((struct sockaddr_in *)addr)->sin_addr), + hostlen); + else + strncpy(*out, "??", hostlen); (*out)[hostlen - 1] = '\0'; return 0; } long -pty_make_sane_hostname(struct sockaddr_in *addr, +pty_make_sane_hostname(struct sockaddr *addr, int maxlen, int strip_ldomain, int always_ipaddr, @@ -69,8 +73,11 @@ pty_make_sane_hostname(struct sockaddr_in *addr, if (always_ipaddr) { return do_ntoa(addr, ut_host_len, out); } - hp = gethostbyaddr((char *)&addr->sin_addr, sizeof (struct in_addr), - addr->sin_family); + if (addr->sa_family == AF_INET) + hp = gethostbyaddr((char *)&((struct sockaddr_in *)addr)->sin_addr, + sizeof (struct in_addr), addr->sa_family); + else + hp = NULL; if (hp == NULL) { return do_ntoa(addr, ut_host_len, out); } |
