Skip to content

Commit

Permalink
Merge pull request #6 from shenfy/fix
Browse files Browse the repository at this point in the history
Bugfix: Wrong buffer length passed to lz4 decompressor
  • Loading branch information
chubei-oppen authored Sep 29, 2021
2 parents c84f10b + 674b053 commit a13d90f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class PagedfileConan(ConanFile):
name = "pagedfile"
version = "1.3.1"
version = "1.3.2"
license = "MIT"
author = "Fangyang Shen [email protected]"
url = "https://github.com/shenfy/pagedfile"
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.17)
project(pfar VERSION 1.3.0 LANGUAGES CXX)
project(pfar VERSION 1.3.2 LANGUAGES CXX)

if (EXISTS ${CMAKE_BINARY_DIR}/conan_paths.cmake)
include(${CMAKE_BINARY_DIR}/conan_paths.cmake)
Expand Down
2 changes: 1 addition & 1 deletion src/src/PagedFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ uint64_t PagedFile::ReadPage(uint32_t idx, char *buffer, size_t buffer_size) {

// loop until src buffer is exhausted or frame end
size_t dst_consumed = 0;
size_t src_left = comp_buffer_.size();
size_t src_left = desc->length;
char *src_buffer = comp_buffer_.data();
while (src_left > 0) {
size_t dst_size = buffer_size - dst_consumed;
Expand Down
7 changes: 5 additions & 2 deletions src/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ class PFArchiver {
if (max_size > input_buffer.size()) {
input_buffer.resize(max_size);
}
pf.ReadPage(idx, &input_buffer[0], max_size);
if (!pf.ReadPage(idx, &input_buffer[0], max_size)) {
std::cerr << "Error: failed to read page " << output_path.string() << std::endl;
continue;
}
output_length = uncompressed_length;
} else {
if (page_length > input_buffer.size()) {
Expand Down Expand Up @@ -456,4 +459,4 @@ int main(int argc, char *argv[]) {

std::cout << "No action requested!" << std::endl << visible << std::endl;
return 0;
}
}

0 comments on commit a13d90f

Please sign in to comment.