Skip to content

fix(vless): dereference packet_encoding in error message to avoid panic#4094

Open
Leadaxe wants to merge 1 commit intoSagerNet:testingfrom
Leadaxe:fix/vless-packet-encoding-panic
Open

fix(vless): dereference packet_encoding in error message to avoid panic#4094
Leadaxe wants to merge 1 commit intoSagerNet:testingfrom
Leadaxe:fix/vless-packet-encoding-panic

Conversation

@Leadaxe
Copy link
Copy Markdown

@Leadaxe Leadaxe commented Apr 28, 2026

Fixes #4093.

protocol/vless/outbound.go:86 passed options.PacketEncoding (a *string) to E.New. common/format.ToString has no case for pointer types, so the call panicked instead of returning the intended error. Adding the dereference makes the path produce a normal FATAL initialize outbound[0]: unknown packet encoding: <value>, matching what the analogous VMess code at protocol/vmess/outbound.go:81 already emits (where PacketEncoding is a plain string).

Verified locally: with the patch applied, sing-box check -c <config-with-packet_encoding-none> returns the FATAL line and exits 1, instead of panic: unknown value + stack trace.

Diff is one character.

`*string` was passed to E.New without dereferencing. format.ToString
has no pointer case, so the intended error became a panic("unknown value"),
crashing the whole process when packet_encoding had an invalid value.
The switch one line above already dereferences; matching that here makes
the call return a normal error like the analogous VMess path does.

Fixes SagerNet#4093.
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

Successfully merging this pull request may close these issues.

[Bug] VLESS outbound: panic("unknown value") instead of error on invalid packet_encoding

1 participant