From 8b00eacabfae37ee9508317c6b3574041e5dba41 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Thu, 25 Feb 2021 23:40:42 -0400 Subject: [PATCH] Fix signed/unsigned char comparison bug These functions would not working properly if given a high bit char value. --- llarp/util/buffer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/llarp/util/buffer.cpp b/llarp/util/buffer.cpp index 6f6bb8831..473bfc5ef 100644 --- a/llarp/util/buffer.cpp +++ b/llarp/util/buffer.cpp @@ -94,8 +94,9 @@ llarp_buffer_t::read_uint64(uint64_t& i) } size_t -llarp_buffer_t::read_until(char delim, byte_t* result, size_t resultsize) +llarp_buffer_t::read_until(char c_delim, byte_t* result, size_t resultsize) { + const auto delim = static_cast(c_delim); size_t read = 0; // do the bound check first, to avoid over running @@ -115,8 +116,9 @@ llarp_buffer_t::read_until(char delim, byte_t* result, size_t resultsize) } bool -operator==(const llarp_buffer_t& buff, const char* str) +operator==(const llarp_buffer_t& buff, const char* c_str) { + const auto* str = reinterpret_cast(c_str); ManagedBuffer copy{buff}; while (*str && copy.underlying.cur != (copy.underlying.base + copy.underlying.sz)) {