|
Line 0
Link Here
|
|
|
1 |
--- src/logwtmp.c.old Sat May 26 16:08:11 2001 |
| 2 |
+++ src/logwtmp.c Sat May 26 16:15:20 2001 |
| 3 |
@@ -46,10 +46,30 @@ |
| 4 |
* after login, but before logout). |
| 5 |
*/ |
| 6 |
void |
| 7 |
-logwtmp(const char *line, const char *name, const char *host) |
| 8 |
+ftpd_logwtmp(const char *line, const char *name, const char *host) |
| 9 |
{ |
| 10 |
struct utmp ut; |
| 11 |
struct stat buf; |
| 12 |
+ |
| 13 |
+ if (strlen(host) > UT_HOSTSIZE) { |
| 14 |
+ struct addrinfo hints, *res; |
| 15 |
+ int error; |
| 16 |
+ static char hostbuf[BUFSIZ]; |
| 17 |
+ |
| 18 |
+ memset(&hints, 0, sizeof(hints)); |
| 19 |
+ hints.ai_family = PF_UNSPEC; |
| 20 |
+ error = getaddrinfo(host, NULL, &hints, &res); |
| 21 |
+ if (error) |
| 22 |
+ host = "invalid hostname"; |
| 23 |
+ else { |
| 24 |
+ getnameinfo(res->ai_addr, res->ai_addrlen, |
| 25 |
+ hostbuf, sizeof(hostbuf), NULL, 0, |
| 26 |
+ NI_NUMERICHOST); |
| 27 |
+ host = hostbuf; |
| 28 |
+ if (strlen(host) > UT_HOSTSIZE) |
| 29 |
+ host[UT_HOSTSIZE] = '\0'; |
| 30 |
+ } |
| 31 |
+ } |
| 32 |
|
| 33 |
if (fd < 0 && (fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0) |
| 34 |
return; |