Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't call open("") backport #1362

Merged
merged 1 commit into from Apr 22, 2022
Merged

Don't call open("") backport #1362

merged 1 commit into from Apr 22, 2022

Commits on Apr 22, 2022

  1. Don't call open("") (urfave#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>
    kolyshkin committed Apr 22, 2022
    Copy the full SHA
    0fbd4f5 View commit details
    Browse the repository at this point in the history