Skip to content

Commands: Fix potential nil pointer dereference in executeAddRules()#5749

Merged
RPRX merged 3 commits intoXTLS:mainfrom
WASDetchan:main
Mar 19, 2026
Merged

Commands: Fix potential nil pointer dereference in executeAddRules()#5749
RPRX merged 3 commits intoXTLS:mainfrom
WASDetchan:main

Conversation

@WASDetchan
Copy link
Copy Markdown
Contributor

See issue #5748. Closes issue #5748.
Previous behavior:

$ ./xray api adrules -s=127.0.0.1:8080 empty_routing.json
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x11330dc]

goroutine 1 [running]:
github.com/xtls/xray-core/main/commands/all/api.executeAddRules(0x2271c80, {0x2557ff0ca030, 0x2, 0x2})
	github.com/xtls/xray-core/main/commands/all/api/rules_add.go:66 +0x3dc
github.com/xtls/xray-core/main/commands/base.Execute()
	github.com/xtls/xray-core/main/commands/base/execute.go:64 +0x59f
main.main()
	github.com/xtls/xray-core/main/main.go:22 +0x1a5

New behavior:

$ ./xray api adrules -s=127.0.0.1:8080 ../empty_routing.json
failed to add routing rule: config did not have "routing" field

Copilot AI added a commit to odlev/Xray-core that referenced this pull request Mar 6, 2026
Co-authored-by: odlev <65655276+odlev@users.noreply.github.com>
@RPRX RPRX changed the title Fix nil pointer dereference in adrules api API: Fix potential nil pointer dereference in executeAddRules() Mar 19, 2026
@RPRX RPRX merged commit ec732b0 into XTLS:main Mar 19, 2026
@RPRX RPRX changed the title API: Fix potential nil pointer dereference in executeAddRules() Commands: Fix potential nil pointer dereference in executeAddRules() Mar 28, 2026
@RPRX
Copy link
Copy Markdown
Member

RPRX commented Mar 28, 2026

刚发现这个更属于 Commands 而非 API

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.

3 participants