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

Fix Wrongly parsed the RESP empty/null array #652

Merged
merged 5 commits into from
Jun 24, 2022

Conversation

willshS
Copy link
Contributor

@willshS willshS commented Jun 23, 2022

This closes #633.

Now : I only fix like:
echo -e '*-1\r\n*2\r\n$3\r\nget\r\n$3\r\nkey\r\n' | nc 127.0.0.1 6666
echo -e '*2\r\n$3\r\nget\r\n$3\r\nkey\r\n*0\r\n*2\r\n$3\r\nget\r\n$3\r\nkey\r\n' | nc 127.0.0.1 6666

Redis can have "nil" value. like:

image

kvrocks also behaves the same way.(I didn't modify anything about "nil" value)

@git-hulk
Copy link
Member

git-hulk commented Jun 23, 2022

Cool, can you add some test cases in protocol.tcl to make sure it has already fixed?

Copy link
Member

@PragmaTwice PragmaTwice left a comment

Choose a reason for hiding this comment

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

Agree with @git-hulk, the rest looks good. Thanks for contribution.

} catch (std::exception &e) {
free(line);
return Status(Status::NotOK, "Protocol error: invalid multibulk length");
}
if (multi_bulk_len_ <= 0) {
Copy link
Member

@PragmaTwice PragmaTwice Jun 23, 2022

Choose a reason for hiding this comment

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

Is an assignment multi_bulk_len_ = 0 needed while the condition multi_bulk_len_ < 0 holds?

Copy link
Member

@PragmaTwice PragmaTwice Jun 23, 2022

Choose a reason for hiding this comment

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

There is a condition if (multi_bulk_len_ == 0) in src/redis_request.cc:111

Copy link
Contributor Author

@willshS willshS Jun 23, 2022

Choose a reason for hiding this comment

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

state_ is still ArrayLen, so it will read again and assign to multi_bulk_len_. it's a good habit that to add the assignment multi_bulk_len_ = 0. Thank you

@willshS
Copy link
Contributor Author

willshS commented Jun 23, 2022

Cool, can you add some test cases in protocol.tcl to make sure it has already fixed?

sure, that's what i should do.

@git-hulk
Copy link
Member

Cool, can you add some test cases in protocol.tcl to make sure it has already fixed?

sure, that's what i should do.

Cool, thanks @willshS

@tisonkun
Copy link
Member

Shall this patch fix #633?

@git-hulk
Copy link
Member

Shall this patch fix #633?

yes

@tisonkun tisonkun changed the title Fix Wrongly parsed the RESP empty/null array (#633) Fix Wrongly parsed the RESP empty/null array Jun 24, 2022
@tisonkun tisonkun merged commit e910200 into apache:unstable Jun 24, 2022
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.

Wrongly parsed the RESP empty/null array
4 participants