Re: [PATCH] mount.cifs: fix buffer overrun in set_password

David Disseldorp
2026-04-01T00:58:33Z

On Tue, 31 Mar 2026 18:56:05 -0500, Steve French wrote:

> added RB from Henrique and updated
> git.samba.org/data/git/cifs-utils.git and
> https://github.com/smfrench/smb3-utils for-next

Thanks Steve. FWIW, the reviewed-by tag has an incorrect email address:
Reviewed-by: Henrique Carvalho <[2]henrique.carvalho@suse.com>
Should be
Reviewed-by: Henrique Carvalho <henrique.carvalho@suse.com>

I'll close the corresponding PR at
https://github.com/smfrench/smb3-utils/pull/16

Cheers, David

> On Mon, Mar 30, 2026 at 7:10 PM David Disseldorp <ddiss@suse.de> wrote:
> >
> > The existing (j > pass_length) check is insufficient to avoid dst buffer
> > overrun into the start of the adjacent struct parsed_mount_info field.
> > Check for overrun before writing to dst, and account for comma-expansion
> > and null-termination.
> >
> > Bug: https://bugzilla.samba.org/show_bug.cgi?id=16044
> >
> > Reported-by: Bruno Bierbaumer <bruno@bierbaumer.net>
> > Signed-off-by: David Disseldorp <ddiss@suse.de>
> > ---
> > mount.cifs.c | 8 ++++----
> > 1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/mount.cifs.c b/mount.cifs.c
> > index 1923913..d41ca6a 100644
> > --- a/mount.cifs.c
> > +++ b/mount.cifs.c
> > @@ -350,13 +350,13 @@ set_password(struct parsed_mount_info *parsed_info, const char *src,
> > unsigned int i = 0, j = 0;
> >
> > while (src[i]) {
> > - if (src[i] == ',')
> > - dst[j++] = ',';
> > - dst[j++] = src[i++];
> > - if (j > pass_length) {
> > + if (j + 2 >= pass_length) {
> > fprintf(stderr, "Converted password too long!\n");
> > return EX_USAGE;
> > }
> > + if (src[i] == ',')
> > + dst[j++] = ',';
> > + dst[j++] = src[i++];
> > }
> > dst[j] = '\0';
> > if (is_pass2)
> > --
> > 2.51.0
> >
>
>