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

Off-by-one problem (maximum non-data Twrite message size is 23, not 24) #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

djs55
Copy link

@djs55 djs55 commented Sep 29, 2015

I've been debugging my 9P implementation [djs55/ocaml-9p] against go9p and noticed a difference in the write message handling. If I'm reading the spec correctly then I think there's an off-by-one in go9p. What do you think?

The manpage describes Twrite as:

size[4] Twrite tag[2] fid[4] offset[8] count[4] data[count]

if count = 0, the message size is 4 + 1 + 2 + 4 + 8 + 4 = 23

This manifests as a bug if a client agrees a maximum message size
with a server, and then computes the maximum value for count
by subtracting 23 i.e. the biggest possible write message. If the
server then checks whether the request is too big by subtracting
24, it will return an error.

Signed-off-by: David Scott [email protected]

The manpage describes Twrite as:

size[4] Twrite tag[2] fid[4] offset[8] count[4] data[count]

if count = 0, the message size is 4 + 1 + 2 + 4 + 8 + 4 = 23

This manifests as a bug if a client agrees a maximum message size
with a server, and then computes the maximum value for `count`
by subtracting 23 i.e. the biggest possible write message. If the
server then checks whether the request is too big by subtracting
24, it will return an error.

Signed-off-by: David Scott <[email protected]>
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.

1 participant