brei: silence warnings on 32-bit architectures

src/brei-shared.c:231:16: warning: comparison of integers of different signs: 'int' and 'uint32_t' (aka 'unsigned int') [-Wsign-compare]
                        if (end - p < len32) {
                            ~~~~~~~ ^ ~~~~~
src/brei-shared.c:233:76: warning: format specifies type 'long' but the argument has type 'int' [-Wformat]
                                                       "Invalid string length %u, only %li bytes remaining", s->len, (end - p) * 4);
                                                                                       ~~~                           ^~~~~~~~~~~~~
                                                                                       %i

Co-authored-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Jan Beich 2023-05-19 13:51:22 +00:00 committed by Peter Hutterer
parent cf932d1efb
commit e27f039b32

View file

@ -225,12 +225,13 @@ brei_demarshal(struct brei_context *brei, struct iobuf *buf, const char *signatu
case 's': {
struct brei_string *s = (struct brei_string *)p;
uint32_t remaining = end - p;
uint32_t protolen = brei_string_proto_length(s->len); /* in bytes */
uint32_t len32 = protolen/4; /* p and end are uint32_t* */
if (end - p < len32) {
if (remaining < len32) {
return brei_result_new(BREI_CONNECTION_DISCONNECT_REASON_PROTOCOL,
"Invalid string length %u, only %li bytes remaining", s->len, (end - p) * 4);
"Invalid string length %u, only %u bytes remaining", s->len, remaining * 4);
}
if (s->len == 0) {