}
ip = net_ip2addr(&auth_request->remote_ip);
- if (ip != NULL) {
+ if (ip[0] != '\0') {
str_append_c(str, ',');
str_append(str, ip);
}
/* These shouldn't fail, and we don't really care if they do. */
host = net_ip2addr(&request->remote_ip);
- if (host != NULL)
+ if (host[0] != '\0')
(void)pam_set_item(pamh, PAM_RHOST, host);
(void)pam_set_item(pamh, PAM_RUSER, request->user);
/* TTY is needed by eg. pam_access module */
strcasecmp(request->service, "IMAP") == 0) {
const char *host = net_ip2addr(&request->remote_ip);
/* vpopmail 5.4 does not understand IPv6 */
- if (host != NULL && IPADDR_IS_V4(&request->remote_ip)) {
+ if (host[0] != '\0' && IPADDR_IS_V4(&request->remote_ip)) {
/* use putenv() directly rather than env_put() which
would leak memory every time we got here. use a
static buffer for putenv() as SUSv2 requirements
addr[MAX_IP_LEN] = '\0';
if (inet_ntop(ip->family, &ip->u.ip6, addr, MAX_IP_LEN) == NULL)
- return NULL;
+ return "";
return t_strdup(addr);
#else
unsigned long ip4;
if (ip->family != AF_INET)
- return NULL;
+ return "";
ip4 = ntohl(ip->u.ip4.s_addr);
return t_strdup_printf("%lu.%lu.%lu.%lu",
unavailable. */
int net_getunixcred(int fd, struct net_unix_cred *cred_r);
-/* Returns ip_addr as string, or NULL if ip is invalid. */
+/* Returns ip_addr as string, or "" if ip isn't valid IPv4 or IPv6 address. */
const char *net_ip2addr(const struct ip_addr *ip);
/* char* -> struct ip_addr translation. */
int net_addr2ip(const char *addr, struct ip_addr *ip);
{
const char *addr = net_ip2addr(host_ip);
- i_assert(addr != NULL);
-
if (host_ip->family == AF_INET) {
str_append(out, addr);
return;
const char *addr;
addr = net_ip2addr(&client->remote_ip);
- if (addr == NULL)
+ if (addr[0] == '\0')
addr = "local";
return addr;
}
} else if (clients_get_count() > 1 || client == NULL) {
process_title_set(t_strdup_printf("[%u connections (%u TLS)]",
clients_get_count(), ssl_proxy_get_count()));
- } else if ((addr = net_ip2addr(&client->ip)) != NULL) {
- process_title_set(t_strdup_printf(client->tls ?
- "[%s TLS]" : "[%s]", addr));
} else {
- process_title_set(client->tls ? "[TLS]" : "");
+ addr = net_ip2addr(&client->ip);
+ if (addr[0] != '\0') {
+ process_title_set(t_strdup_printf(client->tls ?
+ "[%s TLS]" : "[%s]", addr));
+ } else {
+ process_title_set(client->tls ? "[TLS]" : "");
+ }
}
}