Commit 0fbd4f5
committed
Don't call open("") (#1336)
strings.Split(s, sep) returns a slice of a single element containing s
if sep is not found in s. This is true even if s is empty.
As a result, every call to flagFromEnvOrFile results in an attempt to
open a file with empty name. This is seen from strace as
[pid 3287620] openat(AT_FDCWD, "", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 3287620] openat(AT_FDCWD, "", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
...
To fix, check if the string is empty before calling ReadFile.
This also fixes cases where filePath is non-empty but has extra commas.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 3df9a3c)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>1 parent af7fa3d commit 0fbd4f5
1 file changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
341 | | - | |
342 | | - | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
343 | 345 | | |
344 | 346 | | |
345 | 347 | | |
| |||
0 commit comments