mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-17 19:25:54 +02:00
Merge pull request #899 from redboltz/fix_buffer_ptr_size
Fix buffer ptr size
This commit is contained in:
4
.github/workflows/gha.yml
vendored
4
.github/workflows/gha.yml
vendored
@@ -61,7 +61,7 @@ jobs:
|
|||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
# build and test
|
# build and test
|
||||||
CMAKE_CXX_COMPILER="${CXX}" CMAKE_C_COMPILER="${CC}" GTEST_ROOT="${BASE}/usr" CFLAGS="-Werror -g" CXXFLAGS="-Werror -g" ${ACTION}
|
CMAKE_CXX_COMPILER="${CXX}" CMAKE_C_COMPILER="${CC}" GTEST_ROOT="${BASE}/usr" CFLAGS="-Werror -g -fsanitize=undefined" CXXFLAGS="-Werror -g -fsanitize=undefined" ${ACTION}
|
||||||
|
|
||||||
linux:
|
linux:
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-18.04
|
||||||
@@ -172,7 +172,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# build and test
|
# build and test
|
||||||
CMAKE_CXX_COMPILER="${CXX}" CMAKE_C_COMPILER="${CC}" GTEST_ROOT="${BASE}/usr" CFLAGS="-Werror -g" CXXFLAGS="-Werror -g" MSGPACK_SAN="${SAN}" ${ACTION}
|
CMAKE_CXX_COMPILER="${CXX}" CMAKE_C_COMPILER="${CC}" GTEST_ROOT="${BASE}/usr" CFLAGS="-Werror -g -fsanitize=undefined" CXXFLAGS="-Werror -g -fsanitize=undefined" MSGPACK_SAN="${SAN}" ${ACTION}
|
||||||
|
|
||||||
windows:
|
windows:
|
||||||
runs-on: windows-2019
|
runs-on: windows-2019
|
||||||
|
@@ -25,7 +25,7 @@ else
|
|||||||
export ARCH_FLAG="-m64"
|
export ARCH_FLAG="-m64"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cmake -DMSGPACK_32BIT=${BIT32} -DBUILD_SHARED_LIBS=${SHARED} -DMSGPACK_CHAR_SIGN=${CHAR_SIGN} -DCMAKE_CXX_FLAGS=${ARCH_FLAG} ..
|
cmake -DMSGPACK_32BIT=${BIT32} -DBUILD_SHARED_LIBS=${SHARED} -DMSGPACK_CHAR_SIGN=${CHAR_SIGN} -DCMAKE_CXX_FLAGS="${ARCH_FLAG} ${CXXFLAGS}" -DCMAKE_C_FLAGS="${CFLAGS}" ..
|
||||||
|
|
||||||
ret=$?
|
ret=$?
|
||||||
if [ $ret -ne 0 ]
|
if [ $ret -ne 0 ]
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#define MSGPACK_FBUFFER_H
|
#define MSGPACK_FBUFFER_H
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -25,6 +26,9 @@ extern "C" {
|
|||||||
|
|
||||||
static inline int msgpack_fbuffer_write(void* data, const char* buf, size_t len)
|
static inline int msgpack_fbuffer_write(void* data, const char* buf, size_t len)
|
||||||
{
|
{
|
||||||
|
assert(buf || len == 0);
|
||||||
|
if(!buf) return 0;
|
||||||
|
|
||||||
return (1 == fwrite(buf, len, 1, (FILE *)data)) ? 0 : -1;
|
return (1 == fwrite(buf, len, 1, (FILE *)data)) ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -60,7 +60,9 @@ static inline void msgpack_sbuffer_free(msgpack_sbuffer* sbuf)
|
|||||||
static inline int msgpack_sbuffer_write(void* data, const char* buf, size_t len)
|
static inline int msgpack_sbuffer_write(void* data, const char* buf, size_t len)
|
||||||
{
|
{
|
||||||
msgpack_sbuffer* sbuf = (msgpack_sbuffer*)data;
|
msgpack_sbuffer* sbuf = (msgpack_sbuffer*)data;
|
||||||
|
|
||||||
assert(buf || len == 0);
|
assert(buf || len == 0);
|
||||||
|
if(!buf) return 0;
|
||||||
|
|
||||||
if(sbuf->alloc - sbuf->size < len) {
|
if(sbuf->alloc - sbuf->size < len) {
|
||||||
void* tmp;
|
void* tmp;
|
||||||
@@ -83,10 +85,9 @@ static inline int msgpack_sbuffer_write(void* data, const char* buf, size_t len)
|
|||||||
sbuf->alloc = nsize;
|
sbuf->alloc = nsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(buf) {
|
memcpy(sbuf->data + sbuf->size, buf, len);
|
||||||
memcpy(sbuf->data + sbuf->size, buf, len);
|
sbuf->size += len;
|
||||||
sbuf->size += len;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "zone.h"
|
#include "zone.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#if defined(unix) || defined(__unix) || defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__QNX__) || defined(__QNXTO__) || defined(__HAIKU__)
|
#if defined(unix) || defined(__unix) || defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__QNX__) || defined(__QNXTO__) || defined(__HAIKU__)
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
@@ -114,6 +115,9 @@ static inline void msgpack_vrefbuffer_free(msgpack_vrefbuffer* vbuf)
|
|||||||
static inline int msgpack_vrefbuffer_write(void* data, const char* buf, size_t len)
|
static inline int msgpack_vrefbuffer_write(void* data, const char* buf, size_t len)
|
||||||
{
|
{
|
||||||
msgpack_vrefbuffer* vbuf = (msgpack_vrefbuffer*)data;
|
msgpack_vrefbuffer* vbuf = (msgpack_vrefbuffer*)data;
|
||||||
|
assert(buf || len == 0);
|
||||||
|
|
||||||
|
if(!buf) return 0;
|
||||||
|
|
||||||
if(len < vbuf->ref_size) {
|
if(len < vbuf->ref_size) {
|
||||||
return msgpack_vrefbuffer_append_copy(vbuf, buf, len);
|
return msgpack_vrefbuffer_append_copy(vbuf, buf, len);
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
#include "sysdep.h"
|
#include "sysdep.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -121,6 +122,9 @@ static inline int msgpack_zbuffer_write(void* data, const char* buf, size_t len)
|
|||||||
{
|
{
|
||||||
msgpack_zbuffer* zbuf = (msgpack_zbuffer*)data;
|
msgpack_zbuffer* zbuf = (msgpack_zbuffer*)data;
|
||||||
|
|
||||||
|
assert(buf || len == 0);
|
||||||
|
if(!buf) return 0;
|
||||||
|
|
||||||
zbuf->stream.next_in = (Bytef*)buf;
|
zbuf->stream.next_in = (Bytef*)buf;
|
||||||
zbuf->stream.avail_in = (uInt)len;
|
zbuf->stream.avail_in = (uInt)len;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user