Skip to content

Commit 70aad5c

Browse files
Fix parsing mountpoints with spaces
#364
1 parent e74d21c commit 70aad5c

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

src/detection/disk/disk_linux.c

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,31 @@
33
#include <ctype.h>
44
#include <sys/statvfs.h>
55

6+
static void strbufAppendMountPoint(FFstrbuf* mountpoint, const char* source)
7+
{
8+
while(*source != '\0' && !isspace(*source))
9+
{
10+
//Space is encoded as \040
11+
if(strncmp(source, "\\040", 4) == 0)
12+
{
13+
ffStrbufAppendC(mountpoint, ' ');
14+
source += 4;
15+
continue;
16+
}
17+
18+
//Tab is encoded as \011
19+
if(strncmp(source, "\\011", 4) == 0)
20+
{
21+
ffStrbufAppendC(mountpoint, '\t');
22+
source += 4;
23+
continue;
24+
}
25+
26+
ffStrbufAppendC(mountpoint, *source);
27+
++source;
28+
}
29+
}
30+
631
void ffDetectDisksImpl(FFDiskResult* disks)
732
{
833
FILE* mountsFile = fopen("/proc/mounts", "r");
@@ -25,7 +50,7 @@ void ffDetectDisksImpl(FFDiskResult* disks)
2550
if(strncmp(currentPos, "/dev/", 5) != 0 && strncmp(currentPos, "drvfs", 5) != 0)
2651
continue;
2752

28-
//Skip /dev/
53+
//Skip /dev/ or drvfs
2954
currentPos += 5;
3055

3156
//Don't show loop file systems
@@ -41,7 +66,7 @@ void ffDetectDisksImpl(FFDiskResult* disks)
4166
++currentPos;
4267

4368
ffStrbufInitA(&disk->mountpoint, 16);
44-
ffStrbufAppendSUntilC(&disk->mountpoint, currentPos, ' ');
69+
strbufAppendMountPoint(&disk->mountpoint, currentPos);
4570

4671
//Go to filesystem
4772
currentPos += disk->mountpoint.length;

0 commit comments

Comments
 (0)