From 774523f6e2e6278e46376e82cd29275ecae45524 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Thu, 7 Nov 2019 19:35:35 +0100 Subject: [PATCH] Fix missing argument to logit() and clean up unreadable code Found by Coverity Scan Signed-off-by: Joachim Nilsson --- src/syslogd.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/syslogd.c b/src/syslogd.c index 2661f78..116788f 100644 --- a/src/syslogd.c +++ b/src/syslogd.c @@ -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 */