Skip to content
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
10 changes: 7 additions & 3 deletions .github/workflows/gha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,27 +191,31 @@ jobs:
run: |
if (${{ matrix.pattern }} -eq 0) {
$ARCH="x64"
$TRIPLET="x64-windows"
$SHARED="ON"
}
elseif (${{ matrix.pattern }} -eq 1) {
$ARCH="x64"
$TRIPLET="x64-windows"
$SHARED="OFF"
}
elseif (${{ matrix.pattern }} -eq 2) {
$ARCH="Win32"
$TRIPLET="x86-windows"
$SHARED="ON"
}
else {
$ARCH="Win32"
$TRIPLET="x86-windows"
$SHARED="OFF"
}

$CUR=(Get-Location).Path
md build
cd build
cmake -A $ARCH -DBUILD_SHARED_LIBS=$SHARED -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" "-DCMAKE_CXX_FLAGS=/D_VARIADIC_MAX=10 /EHsc /D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING" ..
cmake -A $ARCH -DMSGPACK_BUILD_TESTS=ON -DBUILD_SHARED_LIBS=$SHARED -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" "-DCMAKE_CXX_FLAGS=/D_VARIADIC_MAX=10 /EHsc /D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING" ..
cmake --build . --config Release
$pathbak="$env:PATH"
$env:PATH="C:\vcpkg\installed\x64-windows\bin;$CUR\build\Release;$pathbak"
ctest -V
$env:PATH="C:\vcpkg\installed\$TRIPLET\bin;$CUR\build\Release;$pathbak"
ctest -V -C Release
$env:PATH=$pathbak
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ build_script:
- cd googletest-release-1.7.0
- md build
- cd build
- cmake -G %msvc% -DBUILD_SHARED_LIBS=ON -DCMAKE_CXX_FLAGS=/D_VARIADIC_MAX=10 ..
- cmake -G %msvc% -Dgtest_force_shared_crt=ON -DCMAKE_CXX_FLAGS=/D_VARIADIC_MAX=10 ..
- cmake --build . --config Release
- cd ..
- cd ..
Expand All @@ -35,9 +35,9 @@ build_script:
- cd ..
- md build
- cd build
- cmake -G %msvc% -DGTEST_LIBRARY=%APPVEYOR_BUILD_FOLDER%\googletest-release-1.7.0\build\Release\gtest.lib -DGTEST_MAIN_LIBRARY=%APPVEYOR_BUILD_FOLDER%\googletest-release-1.7.0\build\Release\gtest_main.lib -DGTEST_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\googletest-release-1.7.0\include -DZLIB_LIBRARY=%APPVEYOR_BUILD_FOLDER%\zlib-1.3.2\build\Release\zlib.lib -DZLIB_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\zlib-1.3.2 -DCMAKE_CXX_FLAGS='"/D_VARIADIC_MAX=10 /EHsc"' ..
- cmake -G %msvc% -DMSGPACK_BUILD_TESTS=ON -DGTEST_LIBRARY=%APPVEYOR_BUILD_FOLDER%\googletest-release-1.7.0\build\Release\gtest.lib -DGTEST_MAIN_LIBRARY=%APPVEYOR_BUILD_FOLDER%\googletest-release-1.7.0\build\Release\gtest_main.lib -DGTEST_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\googletest-release-1.7.0\include -DZLIB_LIBRARY=%APPVEYOR_BUILD_FOLDER%\zlib-1.3.2\build\Release\zs.lib -DZLIB_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\zlib-1.3.2 -DCMAKE_CXX_FLAGS='"/D_VARIADIC_MAX=10 /EHsc"' ..
- cmake --build . --config Release -v

test_script:
- set PATH=%PATH%;%APPVEYOR_BUILD_FOLDER%\googletest-release-1.7.0\build\Release;%APPVEYOR_BUILD_FOLDER%\zlib-1.3.2\build\Release;%APPVEYOR_BUILD_FOLDER%\build\release
- ctest -V
- ctest -V -C Release
10 changes: 5 additions & 5 deletions include/msgpack/unpack_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
case 0xc4: // bin 8
case 0xc5: // bin 16
case 0xc6: // bin 32
again_fixed_trail(NEXT_CS(p), 1 << (((unsigned int)*p) & 0x03));
again_fixed_trail(NEXT_CS(p), (size_t)1 << (((unsigned int)*p) & 0x03));
case 0xc7: // ext 8
case 0xc8: // ext 16
case 0xc9: // ext 32
again_fixed_trail(NEXT_CS(p), 1 << ((((unsigned int)*p) + 1) & 0x03));
again_fixed_trail(NEXT_CS(p), (size_t)1 << ((((unsigned int)*p) + 1) & 0x03));
case 0xca: // float
case 0xcb: // double
case 0xcc: // unsigned int 8
Expand All @@ -202,20 +202,20 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
case 0xd1: // signed int 16
case 0xd2: // signed int 32
case 0xd3: // signed int 64
again_fixed_trail(NEXT_CS(p), 1 << (((unsigned int)*p) & 0x03));
again_fixed_trail(NEXT_CS(p), (size_t)1 << (((unsigned int)*p) & 0x03));
case 0xd4: // fixext 1
case 0xd5: // fixext 2
case 0xd6: // fixext 4
case 0xd7: // fixext 8
again_fixed_trail_if_zero(MSGPACK_ACS_EXT_VALUE,
(1 << (((unsigned int)*p) & 0x03)) + 1, _ext_zero);
((size_t)1 << (((unsigned int)*p) & 0x03)) + 1, _ext_zero);
case 0xd8: // fixext 16
again_fixed_trail_if_zero(MSGPACK_ACS_EXT_VALUE, 16+1, _ext_zero);

case 0xd9: // str 8
case 0xda: // str 16
case 0xdb: // str 32
again_fixed_trail(NEXT_CS(p), 1 << ((((unsigned int)*p) & 0x03) - 1));
again_fixed_trail(NEXT_CS(p), (size_t)1 << ((((unsigned int)*p) & 0x03) - 1));
case 0xdc: // array 16
case 0xdd: // array 32
case 0xde: // map 16
Expand Down
6 changes: 3 additions & 3 deletions src/unpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ static inline int template_callback_str(unpack_user* u, const char* b, const cha
}
o->type = MSGPACK_OBJECT_STR;
o->via.str.ptr = p;
o->via.str.size = l;
o->via.str.size = (uint32_t)l;
u->referenced = true;
return 0;
}
Expand All @@ -302,7 +302,7 @@ static inline int template_callback_bin(unpack_user* u, const char* b, const cha
}
o->type = MSGPACK_OBJECT_BIN;
o->via.bin.ptr = p;
o->via.bin.size = l;
o->via.bin.size = (uint32_t)l;
u->referenced = true;
return 0;
}
Expand All @@ -322,7 +322,7 @@ static inline int template_callback_ext(unpack_user* u, const char* b, const cha
o->type = MSGPACK_OBJECT_EXT;
o->via.ext.type = *p;
o->via.ext.ptr = p + 1;
o->via.ext.size = l - 1;
o->via.ext.size = (uint32_t)(l - 1);
u->referenced = true;
return 0;
}
Expand Down
11 changes: 7 additions & 4 deletions test/zbuffer_sizes_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ static int count_deflated_bytes(z_streamp strm, int /* flush */)
#pragma GCC diagnostic pop
#endif //defined(__GNUC__)

// The two tests below need a size_t wider than zlib's uInt. They are guarded
// with the preprocessor rather than a runtime check so that the constants do
// not overflow (and warn) on 32-bit targets.
TEST(zbuffer_sizes, write_length_wider_than_avail_in)
{
if(sizeof(size_t) <= sizeof(uInt)) return;

#if SIZE_MAX > UINT_MAX
const size_t len = static_cast<size_t>(UINT_MAX) + 2;
const char byte = 0;
msgpack_zbuffer zbuf;
Expand All @@ -40,6 +42,7 @@ TEST(zbuffer_sizes, write_length_wider_than_avail_in)
EXPECT_EQ(static_cast<unsigned long long>(len), deflated_bytes);

msgpack_zbuffer_destroy(&zbuf);
#endif // SIZE_MAX > UINT_MAX
}

TEST(zbuffer_sizes, expand_refuses_to_wrap_the_doubled_size)
Expand All @@ -57,8 +60,7 @@ TEST(zbuffer_sizes, expand_refuses_to_wrap_the_doubled_size)

TEST(zbuffer_sizes, expand_keeps_output_space_past_4_gib)
{
if(sizeof(size_t) <= sizeof(uInt)) return;

#if SIZE_MAX > UINT_MAX
msgpack_zbuffer zbuf;
ASSERT_TRUE(msgpack_zbuffer_init(&zbuf, 1, MSGPACK_ZBUFFER_INIT_SIZE));

Expand All @@ -71,4 +73,5 @@ TEST(zbuffer_sizes, expand_keeps_output_space_past_4_gib)
}

msgpack_zbuffer_destroy(&zbuf);
#endif // SIZE_MAX > UINT_MAX
}
Loading