Fix missing argument to logit() and clean up unreadable code

Found by Coverity Scan

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2019-11-07 19:35:35 +01:00
parent 7533f96ca9
commit 774523f6e2

View File

@ -1938,18 +1938,20 @@ const char *cvthname(struct sockaddr_storage *f, int len)
{
static char hname[NI_MAXHOST];
char *p;
int error, count;
int err, count;
if ((error = getnameinfo((struct sockaddr *)f, len,
hname, NI_MAXHOST, NULL, 0, NI_NAMEREQD))) {
logit("Host name for your address (%s) unknown: %s\n", gai_strerror(error));
if ((error = getnameinfo((struct sockaddr *)f, len,
hname, NI_MAXHOST, NULL, 0, NI_NUMERICHOST))) {
logit("Malformed from address: %s\n", gai_strerror(error));
err = getnameinfo((struct sockaddr *)f, len, hname, NI_MAXHOST, NULL, 0, NI_NAMEREQD);
if (err) {
logit("Host name for your address (%s) unknown: %s\n", hname, gai_strerror(err));
err = getnameinfo((struct sockaddr *)f, len, hname, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
if (err) {
logit("Malformed from address: %s\n", gai_strerror(err));
return "???";
}
return hname;
}
/*
* Convert to lower case, just like LocalDomain above
*/