Merge remote-tracking branch 'origin/staging' into staging

pull/320/head
Jeff Becker 6 years ago
commit 6435951e86
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -22,6 +22,7 @@ small_random32(void)
#else #else
unsigned char x[4]; unsigned char x[4];
randombytes(x, 4); randombytes(x, 4);
return x[0] + (x[1] << 8) + (x[2] << 16) + (x[3] << 24); uint32_t x4 = x[3] << 24;
return x[0] + (x[1] << 8) + (x[2] << 16) + x4;
#endif #endif
} }

@ -97,14 +97,15 @@ namespace abyss
bool bool
ShouldProcessHeader(const llarp::string_view& name) const ShouldProcessHeader(const llarp::string_view& name) const
{ {
return name == "content-length" || name == "content-type"; return name == llarp::string_view("content-length")
|| name == llarp::string_view("content-type");
} }
/// return true if we get a 200 status code /// return true if we get a 200 status code
bool bool
HandleStatusCode(string_view code) const HandleStatusCode(string_view code) const
{ {
return code == "200"; return code == string_view("200");
} }
bool bool

@ -103,7 +103,8 @@ namespace abyss
ShouldProcessHeader(const string_view& name) const ShouldProcessHeader(const string_view& name) const
{ {
// TODO: header whitelist // TODO: header whitelist
return name == "content-type" || name == "content-length"; return name == string_view("content-type")
|| name == string_view("content-length");
} }
bool bool
@ -143,7 +144,7 @@ namespace abyss
"text/plain", "text/plain",
"no content type provided"); "no content type provided");
} }
else if(itr->second != "application/json") else if(itr->second != string_view("application/json"))
{ {
return WriteResponseSimple(415, "Unsupported Media Type", return WriteResponseSimple(415, "Unsupported Media Type",
"text/plain", "text/plain",

@ -71,7 +71,8 @@ void
PackedSockAddr::set(const SOCKADDR_STORAGE *sa, socklen_t len) PackedSockAddr::set(const SOCKADDR_STORAGE *sa, socklen_t len)
{ {
// on unix, the cast does nothing, socklen_t is _already_ unsigned // on unix, the cast does nothing, socklen_t is _already_ unsigned
if(sa->ss_family == AF_INET) sockaddr_storage ssa = *sa; // stops member access with misaligned address
if( ssa.ss_family == AF_INET)
{ {
assert((unsigned)len >= sizeof(sockaddr_in)); assert((unsigned)len >= sizeof(sockaddr_in));
const sockaddr_in *sin = (sockaddr_in *)sa; const sockaddr_in *sin = (sockaddr_in *)sa;

@ -215,9 +215,17 @@ endif()
if(WITH_SHARED) if(WITH_SHARED)
add_library(${SHARED_LIB} SHARED ${LIB_SRC}) add_library(${SHARED_LIB} SHARED ${LIB_SRC})
if (WIN32) if (WIN32)
if(USE_LIBABYSS)
target_link_libraries(${SHARED_LIB} ${ABYSS_LIB} ${CRYPTOGRAPHY_LIB} ${LIBS} ${UTIL_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi Threads::Threads)
else()
target_link_libraries(${SHARED_LIB} ${CRYPTOGRAPHY_LIB} ${LIBS} ${UTIL_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi Threads::Threads) target_link_libraries(${SHARED_LIB} ${CRYPTOGRAPHY_LIB} ${LIBS} ${UTIL_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi Threads::Threads)
endif()
else()
if(USE_LIBABYSS)
target_link_libraries(${SHARED_LIB} ${ABYSS_LIB} ${CRYPTOGRAPHY_LIB} ${LIBS} ${UTIL_LIB} libutp ${PLATFORM_LIB} Threads::Threads)
else() else()
target_link_libraries(${SHARED_LIB} ${CRYPTOGRAPHY_LIB} ${LIBS} ${UTIL_LIB} libutp ${PLATFORM_LIB} Threads::Threads) target_link_libraries(${SHARED_LIB} ${CRYPTOGRAPHY_LIB} ${LIBS} ${UTIL_LIB} libutp ${PLATFORM_LIB} Threads::Threads)
endif()
install(TARGETS ${SHARED_LIB} LIBRARY DESTINATION lib) install(TARGETS ${SHARED_LIB} LIBRARY DESTINATION lib)
endif() endif()
add_log_tag(${SHARED_LIB}) add_log_tag(${SHARED_LIB})

@ -1,7 +1,5 @@
#include <util/bencode.h> #include <util/bencode.h>
#include <util/logger.hpp> #include <util/logger.hpp>
#include <cstdlib> #include <cstdlib>
bool bool
@ -75,7 +73,11 @@ bencode_write_bytestring(llarp_buffer_t* buff, const void* data, size_t sz)
bool bool
bencode_write_uint64(llarp_buffer_t* buff, uint64_t i) bencode_write_uint64(llarp_buffer_t* buff, uint64_t i)
{ {
if(!buff->writef("i%lu", i)) #ifndef __LP64__
if(!buff->writef("i%llu", i))
#else
if(!buff->write("i%lu", i))
#endif
{ {
return false; return false;
} }

@ -120,9 +120,16 @@ struct llarp_buffer_t
bool bool
write(InputIt begin, InputIt end); write(InputIt begin, InputIt end);
#ifndef _WIN32
bool bool
writef(const char *fmt, ...) __attribute__((format(printf, 2, 3))); writef(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
; ;
#else
bool
writef(const char *fmt, ...)
__attribute__((__format__(__MINGW_PRINTF_FORMAT, 2, 3)));
;
#endif
bool bool
put_uint16(uint16_t i); put_uint16(uint16_t i);

@ -80,7 +80,8 @@ namespace llarp
Base32Encode(const V& value, Stack& stack) Base32Encode(const V& value, Stack& stack)
{ {
size_t ret = 0, pos = 1; size_t ret = 0, pos = 1;
int bits = 8, tmp = value[0]; int bits = 8;
uint32_t tmp = value[0];
size_t len = value.size(); size_t len = value.size();
while(ret < sizeof(stack) && (bits > 0 || pos < len)) while(ret < sizeof(stack) && (bits > 0 || pos < len))
{ {

Loading…
Cancel
Save