summaryrefslogtreecommitdiffstats
path: root/term-utils/agetty.c
diff options
context:
space:
mode:
authorKarel Zak2013-03-27 14:33:17 +0100
committerKarel Zak2013-03-27 14:33:17 +0100
commit915c1d99f60d81278726e6f4441a80da755c4227 (patch)
tree647944f78fcdf939491cb8e2329f595fc21fd2ba /term-utils/agetty.c
parentlibmount: fix __mnt_optstr_append_option() nonull attribute [coverity scan] (diff)
downloadkernel-qcow2-util-linux-915c1d99f60d81278726e6f4441a80da755c4227.tar.gz
kernel-qcow2-util-linux-915c1d99f60d81278726e6f4441a80da755c4227.tar.xz
kernel-qcow2-util-linux-915c1d99f60d81278726e6f4441a80da755c4227.zip
agetty: make \{4,6} issue file code more robust [coverity scan]
... and more readable for static analyzers Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'term-utils/agetty.c')
-rw-r--r--term-utils/agetty.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index 3c6307a21..7ac12f201 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -1781,7 +1781,6 @@ static void output_ip(sa_family_t family)
if (host && getaddrinfo(host, NULL, &hints, &info) == 0 && info) {
void *addr = NULL;
- char buff[INET6_ADDRSTRLEN + 1];
switch (info->ai_family) {
case AF_INET:
@@ -1791,8 +1790,12 @@ static void output_ip(sa_family_t family)
addr = &((struct sockaddr_in6 *) info->ai_addr)->sin6_addr;
break;
}
- inet_ntop(info->ai_family, (void *) addr, buff, sizeof(buff));
- printf("%s", buff);
+ if (addr) {
+ char buff[INET6_ADDRSTRLEN + 1];
+
+ inet_ntop(info->ai_family, (void *) addr, buff, sizeof(buff));
+ printf("%s", buff);
+ }
freeaddrinfo(info);
}