From c232c6ae7b9a620fe2e9b49a7fa688e59b41052f Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Mon, 26 Nov 2018 18:24:24 +0100 Subject: [PATCH] Small fixes for G++ 7.3 closes #10 --- Makefile | 2 +- include/jwt-cpp/jwt.h | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 5b081dd..aa61412 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ OBJ = $(FSRC:=.o) DEP_DIR = .deps -FLAGS = -fPIC -Wall -Wno-unknown-pragmas -I include +FLAGS = -fPIC -Wall -Wno-unknown-pragmas -Werror -I include CXXFLAGS = -std=c++11 CFLAGS = LINKFLAGS = -lcrypto -lgtest -lpthread diff --git a/include/jwt-cpp/jwt.h b/include/jwt-cpp/jwt.h index 5d9fa64..3528e40 100644 --- a/include/jwt-cpp/jwt.h +++ b/include/jwt-cpp/jwt.h @@ -266,7 +266,7 @@ namespace jwt { return res; } static std::unique_ptr raw2bn(const std::string& raw) { - if(raw[0] >= 0x80) { + if(static_cast(raw[0]) >= 0x80) { std::string str(1, 0x00); str += raw; return std::unique_ptr(BN_bin2bn((const unsigned char*)str.data(), str.size(), nullptr), BN_free); @@ -616,10 +616,25 @@ namespace jwt { switch (str.size() % 4) { case 1: str += alphabet::base64url::fill(); +#ifdef __cpp_attributes +#if __has_cpp_attribute(fallthrough) + [[fallthrough]]; +#endif +#endif case 2: str += alphabet::base64url::fill(); +#ifdef __cpp_attributes +#if __has_cpp_attribute(fallthrough) + [[fallthrough]]; +#endif +#endif case 3: str += alphabet::base64url::fill(); +#ifdef __cpp_attributes +#if __has_cpp_attribute(fallthrough) + [[fallthrough]]; +#endif +#endif default: break; } @@ -710,6 +725,7 @@ namespace jwt { template class verifier { struct algo_base { + virtual ~algo_base() = default; virtual void verify(const std::string& data, const std::string& sig) = 0; }; template