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

If the client connects to the nbd socket, and then disconnects without sending any data, nbd floods the logs #165

Open
jgrills opened this issue May 22, 2024 · 1 comment

Comments

@jgrills
Copy link

jgrills commented May 22, 2024

Since the socket_read() in the server negotiation in negotiate(..) doesn't return any sort of error, the server acts on uninitialized data and can spin around the loop, each read/write spamming the error in socket_closed_negotiate()

@jgrills
Copy link
Author

jgrills commented May 22, 2024

In particular, because magic was used to send the magic number, when it fails to read at https://github.com/NetworkBlockDevice/nbd/blob/master/nbd-server.c#L2678 it will have the correct magic number, and things will proceed.

opt is not initialized and just about anything could happen after that.

As a fix, I might suggest changing socket_read() to memset(buf, 0, len); if the read returns less than 0, here: https://github.com/NetworkBlockDevice/nbd/blob/master/nbd-server.c#L365

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

1 participant