diff options
author | 2007-09-17 07:07:23 +0000 | |
---|---|---|
committer | 2007-09-17 07:07:23 +0000 | |
commit | bb14a393e3af6ff908caaab0513178a93cf62ab8 (patch) | |
tree | c064a898727697a30ec98cf0cd614c3fbb415d4b /lib/libc/net/rcmd.c | |
parent | Do not take wild guesses at how if_enc's internal works, include (diff) | |
download | wireguard-openbsd-bb14a393e3af6ff908caaab0513178a93cf62ab8.tar.xz wireguard-openbsd-bb14a393e3af6ff908caaab0513178a93cf62ab8.zip |
Check snprintf(3) return value for error or truncation.
Mostly path construction, where truncation could be bad.
ok and input from deraadt@ millert@ ray@
Diffstat (limited to 'lib/libc/net/rcmd.c')
-rw-r--r-- | lib/libc/net/rcmd.c | 6 |
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 |