summaryrefslogtreecommitdiffstats
path: root/lib/libc/net/rcmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/net/rcmd.c')
-rw-r--r--lib/libc/net/rcmd.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c
index e2b91994920..30ca6710c4f 100644
--- a/lib/libc/net/rcmd.c
+++ b/lib/libc/net/rcmd.c
@@ -382,10 +382,14 @@ again:
(void)fclose(hostf);
}
if (first == 1 && (__check_rhosts_file || superuser)) {
+ int len;
+
first = 0;
if ((pwd = getpwnam(luser)) == NULL)
return (-1);
- snprintf(pbuf, sizeof pbuf, "%s/.rhosts", pwd->pw_dir);
+ len = snprintf(pbuf, sizeof pbuf, "%s/.rhosts", pwd->pw_dir);
+ if (len < 0 || len >= sizeof pbuf)
+ return (-1);
/*
* Change effective uid while opening .rhosts. If root and