lib/tapi_job: fix send length: use str->len, not str->size#11
Open
okt-konst wants to merge 1 commit into
Open
Conversation
tapi_job_send() was passing str->size (the allocated buffer capacity) to rpc_job_send() instead of str->len (the actual content length). te_string_reserve() rounds the buffer up to growth-factor multiples, so str->size is always >= str->len and often much larger. The excess bytes (zeros beyond the NUL terminator) were serialized into the RPC payload and written to the process's stdin pipe. A single send worked by accident: the process reads line-by-line and the trailing NULs appeared after the newline. On the *second* send those buffered NULs accumulated in the pipe ahead of the new data, prepending garbage to the request, breaking any caller that sends more than one message to a running process (e.g. pyte.remote's JSON protocol). Fix: pass str->len so only the actual content is transmitted. Signed-off-by: Konstantin Ushakov <kushakov@oktet.co.il>
Collaborator
Author
|
@ol-arteman @arybchik could you please review? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tapi_job_send() was passing str->size (the allocated buffer capacity) to
rpc_job_send() instead of str->len (the actual content length).
te_string_reserve() rounds the buffer up to growth-factor multiples, so
str->size is always >= str->len and often much larger.
The excess bytes (zeros beyond the NUL terminator) were serialized into the
RPC payload and written to the process's stdin pipe. A single send worked
by accident: the process reads line-by-line and the trailing NULs appeared
after the newline. On the second send those buffered NULs accumulated in
the pipe ahead of the new data, prepending garbage to the request, breaking
any caller that sends more than one message to a running process.
Fix: pass str->len so only the actual content is transmitted.