From 4a4a5baa82560fddbc4cd24c59fa4dc103950f72 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Date: Sun, 6 Apr 2025 14:19:06 -0400 Subject: [PATCH 1/2] fix: add validation for source stream --- modules/core/include/packio/core/serializable.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/core/include/packio/core/serializable.h b/modules/core/include/packio/core/serializable.h index c93b9ee..3886b1a 100644 --- a/modules/core/include/packio/core/serializable.h +++ b/modules/core/include/packio/core/serializable.h @@ -165,6 +165,10 @@ namespace packio struct DeserializeHelper { static U deserialize(std::istream& stream, const std::array& signature) { + if(stream.bad()){ + throw std::runtime_error("Attempt to deserialize with a bad stream"); + } + // 1) Check signature std::array expectedSig = serializeSignature(); if (!std::equal(signature.begin(), signature.end(), expectedSig.begin())) { @@ -295,6 +299,10 @@ namespace packio template inline void serialize(const T &serializable, std::ostream &stream) { + if(stream.bad()){ + throw std::runtime_error("Attempt to serialize with a bad stream"); + } + // 1) Write out "signature" (unique ID for type T) auto signature = serializeSignature(); writeAll(stream, signature.data(), signature.size(), From 59c4f2b6725dfc5ac612e47d895828e1e2d888b4 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Date: Sun, 6 Apr 2025 14:21:37 -0400 Subject: [PATCH 2/2] ci: fix ci by adding a dev ci on PRs --- .github/workflows/bump-version.yml | 3 --- .github/workflows/dev-ci.yml | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/dev-ci.yml diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index fd44f9b..8627b60 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -4,9 +4,6 @@ on: push: branches: - master - pull_request: - branches: - - master jobs: test-packio: diff --git a/.github/workflows/dev-ci.yml b/.github/workflows/dev-ci.yml new file mode 100644 index 0000000..bfab712 --- /dev/null +++ b/.github/workflows/dev-ci.yml @@ -0,0 +1,25 @@ +--- +name: Bump Packio version +on: + pull_request: + branches: + - master + +jobs: + test-packio: + name: Build and Test on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-13, macos-14] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build C++ project and run C++ tests + run: | + mkdir build && cd build + cmake -DPACKIO_BUILD_TESTS=ON .. && cmake --build . + ctest . + cd .. \ No newline at end of file