diff options
| author | itojun <itojun@NetBSD.org> | 2001-05-09 20:40:50 +0000 |
|---|---|---|
| committer | itojun <itojun@NetBSD.org> | 2001-05-09 20:40:50 +0000 |
| commit | 38c869fbdc15a67f4584a46d1022e2d5616bb017 (patch) | |
| tree | bedbfb09a3bca2d1f3515d77784b8654bb77cb14 /gnu/dist/postfix/src | |
| parent | dd4df24b01ddd9e5ccfff0065d06ff9c2d30fdbf (diff) | |
non-INET6 case fix - remove length limitation on FQDN hostname got from
reverse lookup. PR 12876
Diffstat (limited to 'gnu/dist/postfix/src')
| -rw-r--r-- | gnu/dist/postfix/src/smtpd/smtpd_peer.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/gnu/dist/postfix/src/smtpd/smtpd_peer.c b/gnu/dist/postfix/src/smtpd/smtpd_peer.c index b2cece6b44a..ab480bf557e 100644 --- a/gnu/dist/postfix/src/smtpd/smtpd_peer.c +++ b/gnu/dist/postfix/src/smtpd/smtpd_peer.c @@ -142,9 +142,11 @@ void smtpd_peer_init(SMTPD_STATE *state) )) { #ifdef INET6 char hbuf[NI_MAXHOST]; + char abuf[NI_MAXHOST]; struct addrinfo hints, *rnull = NULL; #else - char hbuf[sizeof("255.255.255.255") + 1]; + char abuf[sizeof("255.255.255.255") + 1]; + char *hbuf; #endif int error = -1; @@ -152,17 +154,17 @@ void smtpd_peer_init(SMTPD_STATE *state) (void)getnameinfo(sa, len, hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST); #else in = &((struct sockaddr_in *)sa)->sin_addr; - inet_ntop(AF_INET, in, hbuf, sizeof(hbuf)); + inet_ntop(AF_INET, in, abuf, sizeof(abuf)); #endif - state->addr = mystrdup(hbuf); + state->addr = mystrdup(abuf); #ifdef INET6 error = getnameinfo(sa, len, hbuf, sizeof(hbuf), NULL, 0, NI_NAMEREQD); #else + hbuf = NULL; hp = gethostbyaddr((char *)in, sizeof(*in), AF_INET); if (hp && strlen(hp->h_name) < sizeof(hbuf) - 1) { error = 0; - strncpy(hbuf, hp->h_name, sizeof(hbuf) - 1); - hbuf[sizeof(hbuf) - 1] = '\0'; + hbuf = mystrdup(hp->h_name); } else error = 1; #endif @@ -227,6 +229,11 @@ void smtpd_peer_init(SMTPD_STATE *state) } #endif } + +#ifndef INET6 + if (hbuf) + myfree(hbuf); +#endif } /* |
