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

bugfix for resp parser #4

Merged
merged 3 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace.package]
version = "0.3.0"
version = "0.3.1"
edition = "2021"
homepage = "https://pelikan.io"
repository = "https://github.com/pelikan-io/pelikan"
Expand Down
23 changes: 22 additions & 1 deletion src/protocol/resp/src/request/badd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,41 @@ impl TryFrom<Message> for BAddRequest {
return Err(Error::new(ErrorKind::Other, "malformed command"));
}

let _command = take_bulk_string(&mut array)?;

let outer_key = take_bulk_string(&mut array)?;

if outer_key.is_none() {
return Err(Error::new(ErrorKind::Other, "malformed command"));
}

let outer_key = outer_key.unwrap();

if outer_key.is_empty() {
return Err(Error::new(ErrorKind::Other, "malformed command"));
}

//loop as long as we have at least 2 arguments after the command
let mut pairs = Vec::with_capacity(array.len() / 2);
while array.len() >= 3 {
while array.len() >= 2 {
let inner_key = take_bulk_string(&mut array)?;
if inner_key.is_none() {
return Err(Error::new(ErrorKind::Other, "malformed command"));
}
let inner_key = inner_key.unwrap();

if inner_key.is_empty() {
return Err(Error::new(ErrorKind::Other, "malformed command"));
}

let value = take_bulk_string(&mut array)?;

if value.is_none() {
return Err(Error::new(ErrorKind::Other, "malformed command"));
}

let value = value.unwrap();

if value.is_empty() {
return Err(Error::new(ErrorKind::Other, "malformed command"));
}
Expand Down
Loading