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

Malformed JSON can crash server #1049

Closed
jorants opened this issue Sep 8, 2022 · 2 comments
Closed

Malformed JSON can crash server #1049

jorants opened this issue Sep 8, 2022 · 2 comments

Comments

@jorants
Copy link

jorants commented Sep 8, 2022

Describe the bug
An empty JSON message crashed snapserver.

Steps to Reproduce

  1. Send a message that should contain JSON, for example a Hello message, but that has length 0. e.g. i accedently send this one which has 0 as a payload size in the hello part:
    \x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xdc\x00\x00\x00\x00\x00\x00\x00{"Arch": "x86_64", "ClientName": "Snapclient", "HostName": "my_hostname", "ID": "00:11:22:33:44:55", "Instance": 1, "MAC": "00:11:22:33:44:55", "OS": "Arch Linux", "SnapStreamProtocolVersion": 2, "Version": "0.17.1"}
  2. Snapserver crashes

Environment details

  • OS: debian
  • Snapcast version c0.26.0
  • Installed from AUR

Attach logfile if applicable
snapserver --logging.filter debug:

2022-09-08 16-19-12.115 [Notice] (StreamServer) StreamServer::NewConnection: 127.0.0.1
2022-09-08 16-19-12.115 [Debug] (StreamSessionTCP) getNextMessage: Hello, size: 220, id: 0, refers: 0
2022-09-08 16-19-12.115 [Debug] (Server) onMessageReceived: Hello, size: 220, id: 0, refers: 0, sent: 0,0, recv: 17345,333810
2022-09-08 16-19-12.115 [Debug] (StreamSessionTCP) ~StreamSessionTcp
2022-09-08 16-19-12.115 [Debug] (StreamSessionTCP) stop
2022-09-08 16-19-12.115 [Debug] (StreamSessionTCP) stopped
terminate called after throwing an instance of 'nlohmann::detail::parse_error'
  what():  [json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal
[1]    36593 IOT instruction (core dumped)  snapserver --logging.filter debug

@badaix
Copy link
Owner

badaix commented Sep 9, 2022

Should be fixed in develop branch 0da026a. Can you please test it?

@badaix
Copy link
Owner

badaix commented Feb 5, 2023

Fixed in snapcast v0.27.0

@badaix badaix closed this as completed Feb 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants