cmsfs-fuse: Fix strip_right() function

strip_right() strips spaces beginning at the end of the string moving
to the beginning. However, it doesn't check whether it's at beginning
of the array, and would continue reading if the string only contains
spaces.

Fix this by adding the necessary check.

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
Reviewed-by: Mete Durlu <meted@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Sven Schnelle
2026-06-29 16:16:51 +02:00
committed by Jan Höppner
parent b38d5833fa
commit 162a041077

View File

@@ -713,7 +713,7 @@ static int readdir_entry(struct fst_entry *fst, off_t addr)
*/
static inline int strip_right(const char *str, int size)
{
while (str[size - 1] == 0x20)
while (size > 0 && str[size - 1] == 0x20)
size--;
return size;
}