[PATCH 2/3] mount.cifs: adjust get_password_from_file() buf size

David Disseldorp
2026-03-31T01:25:42Z

The parsed_mount_info password and password2 fields are both zero
terminated and sized MOUNT_PASSWD_SIZE + 1.
The get_password_from_file() buf adds one to this size, presumably to
account for (extra) zero termination. This is unnecessary, so use a
consistent size across all buffers.

Signed-off-by: David Disseldorp <ddiss@suse.de>
---
mount.cifs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mount.cifs.c b/mount.cifs.c
index d41ca6a..945196f 100644
--- a/mount.cifs.c
+++ b/mount.cifs.c
@@ -684,7 +684,7 @@ get_password_from_file(int file_descript, char *filename,
int is_pass2 = which_pass == OPT_PASS2;
unsigned int pass_length = is_pass2 ?
sizeof(parsed_info->password2) : sizeof(parsed_info->password);
- char buf[pass_length + 1];
+ char buf[pass_length];

if (filename != NULL) {
rc = toggle_dac_capability(0, 1);
--
2.51.0