libfuse: null-terminate buffer in fuse_req_getgroups()
authorMiklos Szeredi <mszeredi@redhat.com>
Thu, 13 Jun 2024 11:57:25 +0000 (13:57 +0200)
committerBernd Schubert <bernd.schubert@fastmail.fm>
Thu, 13 Jun 2024 14:39:54 +0000 (16:39 +0200)
After reading the file /proc/$PID/task/$PID/status the buffer wasn't
terminated with a null character.  This could theoretically lead to buffer
overrun by the subsequent strstr() call.

Since the contents of the proc file are guaranteed to contain the pattern
that strstr is looking for, this doesn't happen in normal situations.

Add null termination for robustness.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
lib/fuse_lowlevel.c

index fc4688247e9bb7cf17f4da73bb71c79cc4fd1296..74b04247812226a4e64078f2266b1d01a79dc450 100644 (file)
@@ -3353,6 +3353,7 @@ retry:
                goto retry;
        }
 
+       buf[ret] = '\0';
        ret = -EIO;
        s = strstr(buf, "\nGroups:");
        if (s == NULL)