summaryrefslogtreecommitdiffhomepage
path: root/svr-authpubkey.c
diff options
context:
space:
mode:
Diffstat (limited to 'svr-authpubkey.c')
-rw-r--r--svr-authpubkey.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/svr-authpubkey.c b/svr-authpubkey.c
index ae1402d..dafa99a 100644
--- a/svr-authpubkey.c
+++ b/svr-authpubkey.c
@@ -424,8 +424,9 @@ static int checkpubkeyperms() {
/* allocate max required pathname storage,
* = path + "/.ssh/authorized_keys" + '\0' = pathlen + 22 */
- filename = m_malloc(len + 22);
- strncpy(filename, ses.authstate.pw_dir, len+1);
+ len += 22;
+ filename = m_malloc(len);
+ strlcpy(filename, ses.authstate.pw_dir, len);
/* check ~ */
if (checkfileperm(filename) != DROPBEAR_SUCCESS) {
@@ -433,13 +434,13 @@ static int checkpubkeyperms() {
}
/* check ~/.ssh */
- strncat(filename, "/.ssh", 5); /* strlen("/.ssh") == 5 */
+ strlcat(filename, "/.ssh", len);
if (checkfileperm(filename) != DROPBEAR_SUCCESS) {
goto out;
}
/* now check ~/.ssh/authorized_keys */
- strncat(filename, "/authorized_keys", 16);
+ strlcat(filename, "/authorized_keys", len);
if (checkfileperm(filename) != DROPBEAR_SUCCESS) {
goto out;
}