Skip to content
This repository has been archived by the owner on Apr 18, 2018. It is now read-only.

Fixed handling of null chars in arguments. No 'ascii' checks. #26

Merged
merged 1 commit into from
Sep 6, 2012
Merged

Fixed handling of null chars in arguments. No 'ascii' checks. #26

merged 1 commit into from
Sep 6, 2012

Conversation

eskil
Copy link
Contributor

@eskil eskil commented Sep 5, 2012

The protocol says;
"Arguments given in the data part are separated by a NULL byte, and
the last argument is determined by the size of data after the last
NULL byte separator. All job handle arguments must not be longer than
64 bytes, including NULL terminator."

This adds a check to ensure that all arguments, but the last, do
not contain \0.

I do not check the args pass encode('ascii'). It would make sense,
since it's not known what will happen inside the bowels of gearmand.
It uses memcmp for the most part, and we have to assume the
queue storage can handle utf8, as long as it does not contain
\0.

The protocol says;
"Arguments given in the data part are separated by a NULL byte, and
the last argument is determined by the size of data after the last
NULL byte separator. All job handle arguments must not be longer than
64 bytes, including NULL terminator."

This adds a check to ensure that all arguments, but the last, do
not contain \0.

I do not check the args pass encode('ascii'). It would make sense,
since it's not known what will happen inside the bowels of gearmand.
It uses memcmp for the most part, and we have to assume the
queue storage can handle utf8, as long as it does not contain
\0.

# Assert we check for NULLs in all but the "last" argument, where last depends on the cmd_type.
cmd_type = protocol.GEARMAN_COMMAND_SUBMIT_JOB
cmd_args = dict(task='function', data='abcd', unique='123\x0045')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't the last argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, the order of arguments is based on keys, and decided in protocol.py. Hence the "quotes" around last.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand why "unique" isn't last, then.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, eskil explained this to me. I am just bad at reading.

@Roguelazer
Copy link

shipit

eskil added a commit that referenced this pull request Sep 6, 2012
Fixed handling of null chars in arguments. No 'ascii' checks.
@eskil eskil merged commit 7e967d9 into Yelp:master Sep 6, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants