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

Example, register/client SIGSEGV case when Algorithm in lowercase. #24

Closed
tkang007 opened this issue Jun 2, 2023 · 9 comments
Closed

Comments

@tkang007
Copy link

tkang007 commented Jun 2, 2023

Hi,
I would like to report an issue when register to an Asterisk with the example/register/client/main.go

$  ./client -ip 192.168.219.101:15060 -srv 192.168.219.101:5060 -u 100 -p 100
...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x648827]

goroutine 1 [running]:
github.com/icholy/digest.(*Credentials).String(0x0)
        /home/vagrant/go/pkg/mod/github.com/icholy/digest@v0.1.22/credentials.go:76 +0x67
main.main()
        /home/vagrant/sipgo/example/register/client/main.go:101 +0xe05

Could be fixed by changing Algorithm to uppercase as it was expected by digest.Digest method.

...
		wwwAuth := res.GetHeader("WWW-Authenticate")
		chal, err := digest.ParseChallenge(wwwAuth.Value())
		if err != nil {
			log.Fatal().Str("wwwauth", wwwAuth.Value()).Err(err).Msg("Fail to parse challenge")
		}
		chal.Algorithm = strings.ToUpper(chal.Algorithm)   //##### fixing
...

Asterisk's WWW-Authenticate parsed challenge:

github.com/icholy/digest.Challenge {Realm: "asterisk", Domain: []string len: 0, cap: 0, nil, Nonce: "1685669327/dfd8ceb694344a6f663b95f91eb48096", Opaque: "2ac5572d63798b56", Stale: false, Algorithm: "md5", QOP: []string len: 1, cap: 1, ["auth"], Charset: "", Userhash: false}

Thanks.

@tkang007 tkang007 closed this as completed Jun 2, 2023
@tkang007
Copy link
Author

tkang007 commented Jun 2, 2023

just for sharing

@emiago
Copy link
Owner

emiago commented Jun 3, 2023

Hi @tkang007 maybe to create a PR. Not sure is some digest lib issue.

@r4hx
Copy link

r4hx commented Oct 16, 2024

Yes. It is issue belong digest. I made PR for fix it icholy/digest#11 or you can use my fork https://github.com/r4hx/digest

You need just add to your go.mod

replace github.com/icholy/digest => github.com/r4hx/digest v0.0.1

and run command in terminal

go mod tidy

@emiago
Copy link
Owner

emiago commented Oct 16, 2024

@r4hx I only noticed this issue couple days ago and it is older version of asterisk (16). I guess they fixed on their end in newer version.
Let me know when your PR merges

@r4hx
Copy link

r4hx commented Oct 16, 2024

@r4hx I only noticed this issue couple days ago and it is older version of asterisk (16). I guess they fixed on their end in newer version. Let me know when your PR merges

My PR will not be merge, because maintainer reject it. He gave an another solution which more clearly (maybe, i not a golang programmer :D) and simply. But my solution still worked, we have a two tweak how to solve this problem now.

@emiago
Copy link
Owner

emiago commented Oct 16, 2024

yes he is right about rfc. Still solution he provides seems something related to HTTP?

@emiago emiago reopened this Oct 16, 2024
@r4hx
Copy link

r4hx commented Oct 16, 2024

Still solution he provides seems something related to HTTP?

No, it’s solution related to udp (header of packet).

@emiago
Copy link
Owner

emiago commented Oct 17, 2024

hi @r4hx fixed on client.

@emiago emiago closed this as completed Oct 17, 2024
@r4hx
Copy link

r4hx commented Oct 17, 2024

hi @r4hx fixed on client.

Nice work. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants