xapi-project / nbd

Ocaml NBD library
https://xapi-project.github.io/nbd/
Other
14 stars 16 forks source link

Client.list does not parse server response properly #103

Closed gaborigloi closed 6 years ago

gaborigloi commented 7 years ago

It expects one more 32 bit int than what the protocol describes. This is because it seems to parse the length twice in the code.

To prevent such issues, we could add a new kind of unit test, which connects the server and the client together. We could also add an integration-style test, provided we can run the nbd-client / nbd-server programs on Travis.

gaborigloi commented 6 years ago

I've realized that I'm wrong, it parses the responses correctly. The NBD protocol says:

NBD_REP_SERVER (2)

A description of an export. Data:

32 bits, length of name (unsigned); MUST be no larger than the reply packet header length - 4

String, name of the export, as expected by NBD_OPT_EXPORT_NAME, NBD_OPT_INFO, or NBD_OPT_GO

If length of name < (reply packet header length - 4), then the rest of the data contains some implementation-specific details about the export. This is not currently implemented, but future versions of nbd-server may send along some details about the export. Therefore, unless explicitly documented otherwise by a particular client request, this field is defined to be a string suitable for direct display to a human being.