mihomo icon indicating copy to clipboard operation
mihomo copied to clipboard

fix: when 'data' is nil, panic occurs

Open Luoxin opened this issue 1 year ago • 1 comments

Luoxin avatar Sep 20 '24 08:09 Luoxin

https://github.com/MetaCubeX/mihomo/blob/f020b20ab932bd68108fed34323add4d20e7236e/common/structure/structure.go#L74 It has been ensured that the decode input parameter data is not nil. Is there a clear location that causes panic? Could you add a unit test?

Skyxim avatar Sep 20 '24 08:09 Skyxim

https://github.com/MetaCubeX/mihomo/blob/f020b20ab932bd68108fed34323add4d20e7236e/common/structure/structure.go#L251

The location where the panic occurred is /common/structure/structure.go:251. The error reported at that time was because dataVal was Zero, which caused the dataValue.Type() call in the default branch to throw panic. The original error message is

panic: reflect: call of reflect.Value.Type on zero Value

After searching, it was found that the value of h2-opts.path in the configuration was set to nil. The original source of the configuration is not yet known. Related unit tests have been added.

Luoxin avatar Sep 21 '24 22:09 Luoxin

After searching, it was found that the value of h2-opts.path in the configuration was set to nil.

It seems that the value in the map is not checked. Just add the check here.https://github.com/MetaCubeX/mihomo/blob/f020b20ab932bd68108fed34323add4d20e7236e/common/structure/structure.go#L370

Skyxim avatar Sep 22 '24 04:09 Skyxim

https://github.com/MetaCubeX/mihomo/commit/3f6823ba49a5f82fa0ca7355ce75a94346d057a2

wwqgtxx avatar Dec 16 '24 01:12 wwqgtxx