BUG/MINOR: Wrong type used as argument for spoe_decode_buffer().

Contrary to 64-bits libCs where size_t type size is 8, on systems with 32-bits
size of size_t is 4 (the size of a long) which does not equal to size of uint64_t type.
This was revealed by such GCC warnings on 32bits systems:

src/flt_spoe.c:2259:40: warning: passing argument 4 of spoe_decode_buffer from
incompatible pointer type
  if (spoe_decode_buffer(&p, end, &str, &sz) == -1)
                                         ^
As the already existing code using spoe_decode_buffer() already use such pointers to
uint64_t, in place of pointer to size_t ;), most of this code is in contrib directory,
this simple patch modifies the prototype of spoe_decode_buffer() so that to use a
pointer to uint64_t in place of a pointer to size_t, uint64_t type being the type
finally required for decode_varint().
This commit is contained in:
Frdric Lcaille 2017-08-22 10:33:14 +02:00 committed by Willy Tarreau
parent a5480694bf
commit 6ca71a9297
2 changed files with 5 additions and 6 deletions

View File

@ -92,7 +92,7 @@ spoe_encode_frag_buffer(const char *str, size_t len, char **buf, char *end)
* On success, it returns the buffer length and <*buf> is moved after the
* encoded buffer. Otherwise, it returns -1. */
static inline int
spoe_decode_buffer(char **buf, char *end, char **str, size_t *len)
spoe_decode_buffer(char **buf, char *end, char **str, uint64_t *len)
{
char *p = *buf;
uint64_t sz;
@ -248,8 +248,7 @@ spoe_skip_data(char **buf, char *end)
{
char *str, *p = *buf;
int type, ret;
size_t sz;
uint64_t v;
uint64_t v, sz;
if (p >= end)
return -1;
@ -296,7 +295,7 @@ spoe_decode_data(char **buf, char *end, struct sample *smp)
{
char *str, *p = *buf;
int type, r = 0;
size_t sz;
uint64_t sz;
if (p >= end)
return -1;

View File

@ -655,7 +655,7 @@ spoe_handle_agenthello_frame(struct appctx *appctx, char *frame, size_t size)
vsn = max_frame_size = flags = 0;
while (p < end) {
char *str;
size_t sz;
uint64_t sz;
int ret;
/* Decode the item key */
@ -836,7 +836,7 @@ spoe_handle_agentdiscon_frame(struct appctx *appctx, char *frame, size_t size)
/* Loop on K/V items */
while (p < end) {
char *str;
size_t sz;
uint64_t sz;
int ret;
/* Decode the item key */