NFSD: Stricter buffer size checking in write_recoverydir()

While it's not likely a pathname will be longer than
SIMPLE_TRANSACTION_SIZE, we should be more careful about just
plopping it into the output buffer without bounds checking.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
This commit is contained in:
Chuck Lever 2009-04-23 19:33:10 -04:00 committed by J. Bruce Fields
parent 017cb47f46
commit 3d72ab8fdd
1 changed files with 3 additions and 2 deletions

View File

@ -1260,8 +1260,9 @@ static ssize_t __write_recoverydir(struct file *file, char *buf, size_t size)
status = nfs4_reset_recoverydir(recdir);
}
sprintf(buf, "%s\n", nfs4_recoverydir());
return strlen(buf);
return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%s\n",
nfs4_recoverydir());
}
/**