Repository navigation
IPv6 literals in remotes triggers SIGSEGV #8703
Description
Activity
The error being ignored here looks awfully suspicious: https://github.com/cli/go-gh/blob/d88d88f917cd4e0bcaa582bac2bb909bd79f9759/pkg/ssh/ssh.go#L42
I don't have time to investigate this further right now but I would welcome someone to come take a look at this.
- addedpriority-3Affects a small number of users or is largely cosmeticAffects a small number of users or is largely cosmetichelp wantedContributions welcomeContributions welcomeand removedneeds-triageneeds to be reviewedneeds to be reviewed
on Feb 15, 2024 @williammartin Thanks for the hint. I just pushed a PR to fix this, which just touches the code in this repo.
As a side note regarding the masked error, I think we can improve the
Translatemethod's signature to also return an error. This way, we don't need to ignore the error and we can just return it to the caller. I expect the changes to both cli/go-gh and cli/cli to be minimal (of course, unless there's no other project/code that depends on the same method), but I don't know if it's okay with you. Please let me know if you think we should do that, and I'll submit further PRs.@babakks I am always in favour of bubbling errors and being explicit about handling them, even if the behaviour remains the same. See also here:
Lines 109 to 112 in 2c53d7c
repo, _ = ghrepo.FromURL(translator.Translate(r.FetchURL)) } if r.PushURL != nil && repo == nil { repo, _ = ghrepo.FromURL(translator.Translate(r.PushURL)) The first return value is being used as a proxy for the error cases. It's extremely confusing because it twists successful cases and error cases into one, and makes it harder to change later; you have to go and read the implementation of the
FromURLfunction to understand whether error cases are always the same asnilin the first return. This has been a source of a number of bugs I've discovered.However, we have a bit of an issue because changing the signature is technically a breaking change in
go-gh. Being pragmatic, I don't think anyone is really going to be bothered if we changed it in a minor version but I could be wrong. I'm not even sure anyone else uses this package aside fromcli/cli. 🤔
Describe the bug
Having an IPv6 literal in a remote url causes SIGSEGV in
gh pr create.Steps to reproduce the behavior
ssh://git@[::1]:22/tmp/git-repogh pr createExpected vs actual behavior
I'd expect this to work without a segfault, even if there's a remote using IPv6 literals.
Logs