Skip to content

Commit 68710c4

Browse files
danobi4ast
authored andcommitted
syms: Initialize ModulePath::fd_ to invalid FD
~ModulePath() does `if (fd_ > 0) close fd_;`. But ModulePath constructor has early return codepath for `!enter_ns` which does not initialize `fd_`. So `fd_` can potentially have junk value. That junk value could be any FD downstream. bcc cannot be closing random FDs.
1 parent fea5b15 commit 68710c4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/cc/syms.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class ProcSyms : SymbolCache {
130130
// process by storing a file descriptor created from openat(2) if possible
131131
// if openat fails, falls back to process-dependent path with /proc/.../root
132132
private:
133-
int fd_;
133+
int fd_ = -1;
134134
std::string proc_root_path_;
135135
std::string path_;
136136

0 commit comments

Comments
 (0)