dirclient: don't return too-long responses on decompression failure
There are a couple of places where we forgot to truncate our return-buffer to its actual size, and instead returned a big bunch of zeros. Found while writing the tests in the next commit. Someday, we'll have ReadBuf and won't have to worry about these things.
This commit is contained in:
parent
81a49fb6ec
commit
7fdde559d4
|
@ -307,12 +307,14 @@ where
|
|||
let status = futures::select! {
|
||||
status = stream.read(buf).fuse() => status,
|
||||
_ = timer => {
|
||||
result.resize(written_total, 0); // truncate as needed
|
||||
return Err(Error::DirTimeout);
|
||||
}
|
||||
};
|
||||
let written_in_this_loop = match status {
|
||||
Ok(n) => n,
|
||||
Err(other) => {
|
||||
result.resize(written_total, 0); // truncate as needed
|
||||
return Err(other.into());
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue