Skip to content

Commit 0b171c2

Browse files
committed
mountinfo: also unescape fstype and source
Just noticed it while reading the kernel source code (function show_mountinfo() in fs/proc_namespace.c; see also: show_type(), mangle()) that the first two fields after the `-` separator are also escaped. While I haven't seen it in real life, it's better we unescape them. No field-specific tests were added, and unescape() is tested by its own test case. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 504ee4b commit 0b171c2

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

mountinfo/mountinfo_linux.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,14 @@ func parseInfoFile(r io.Reader, filter FilterFunc) ([]*Info, error) {
7575
if err != nil {
7676
return nil, fmt.Errorf("Parsing '%s' failed: mount point: %w", fields[4], err)
7777
}
78-
p.Fstype = fields[sepIdx+1]
79-
p.Source = fields[sepIdx+2]
78+
p.Fstype, err = unescape(fields[sepIdx+1])
79+
if err != nil {
80+
return nil, fmt.Errorf("Parsing '%s' failed: fstype: %w", fields[sepIdx+1], err)
81+
}
82+
p.Source, err = unescape(fields[sepIdx+2])
83+
if err != nil {
84+
return nil, fmt.Errorf("Parsing '%s' failed: source: %w", fields[sepIdx+2], err)
85+
}
8086
p.VfsOpts = fields[sepIdx+3]
8187

8288
// Run a filter soon so we can skip parsing/adding entries

0 commit comments

Comments
 (0)