Merge commit 'b1c5732' into logging_enabled

This commit is contained in:
Richard van der Hoff 2016-06-28 14:29:17 +01:00
commit 2f8d7ba80e
5 changed files with 11 additions and 11 deletions

View file

@ -24,9 +24,9 @@ JS_PRE := $(wildcard javascript/*pre.js)
JS_POST := $(wildcard javascript/*post.js) JS_POST := $(wildcard javascript/*post.js)
CPPFLAGS += -Iinclude -Ilib CPPFLAGS += -Iinclude -Ilib
CFLAGS += -Wall -std=c89 -fPIC CFLAGS += -Wall -Werror -std=c89 -fPIC
CXXFLAGS += -Wall -std=c++11 -fPIC CXXFLAGS += -Wall -Werror -std=c++11 -fPIC
LDFLAGS += -Wall LDFLAGS += -Wall -Werror
EMCCFLAGS = --closure 1 --memory-init-file 0 -s NO_FILESYSTEM=1 -s INVOKE_RUN=0 EMCCFLAGS = --closure 1 --memory-init-file 0 -s NO_FILESYSTEM=1 -s INVOKE_RUN=0
# NO_BROWSER is kept for compatibility with emscripten 1.35.24, but is no # NO_BROWSER is kept for compatibility with emscripten 1.35.24, but is no

View file

@ -136,7 +136,7 @@ static std::uint8_t const * decode(
std::uint8_t const * len_start = pos; std::uint8_t const * len_start = pos;
pos = varint_skip(pos, end); pos = varint_skip(pos, end);
std::size_t len = varint_decode<std::size_t>(len_start, pos); std::size_t len = varint_decode<std::size_t>(len_start, pos);
if (len + pos > end) return end; if (len > std::size_t(end - pos)) return end;
value = pos; value = pos;
value_length = len; value_length = len;
pos += len; pos += len;
@ -157,7 +157,7 @@ static std::uint8_t const * skip_unknown(
std::uint8_t const * len_start = pos; std::uint8_t const * len_start = pos;
pos = varint_skip(pos, end); pos = varint_skip(pos, end);
std::size_t len = varint_decode<std::size_t>(len_start, pos); std::size_t len = varint_decode<std::size_t>(len_start, pos);
if (len + pos > end) return end; if (len > std::size_t(end - pos)) return end;
pos += len; pos += len;
} else { } else {
return end; return end;

View file

@ -191,7 +191,7 @@ const char * olm_account_last_error(
OlmAccount * account OlmAccount * account
) { ) {
unsigned error = unsigned(from_c(account)->last_error); unsigned error = unsigned(from_c(account)->last_error);
if (error < sizeof(ERRORS)) { if (error < (sizeof(ERRORS)/sizeof(ERRORS[0]))) {
return ERRORS[error]; return ERRORS[error];
} else { } else {
return "UNKNOWN_ERROR"; return "UNKNOWN_ERROR";
@ -203,7 +203,7 @@ const char * olm_session_last_error(
OlmSession * session OlmSession * session
) { ) {
unsigned error = unsigned(from_c(session)->last_error); unsigned error = unsigned(from_c(session)->last_error);
if (error < sizeof(ERRORS)) { if (error < (sizeof(ERRORS)/sizeof(ERRORS[0]))) {
return ERRORS[error]; return ERRORS[error];
} else { } else {
return "UNKNOWN_ERROR"; return "UNKNOWN_ERROR";
@ -214,7 +214,7 @@ const char * olm_utility_last_error(
OlmUtility * utility OlmUtility * utility
) { ) {
unsigned error = unsigned(from_c(utility)->last_error); unsigned error = unsigned(from_c(utility)->last_error);
if (error < sizeof(ERRORS)) { if (error < (sizeof(ERRORS)/sizeof(ERRORS[0]))) {
return ERRORS[error]; return ERRORS[error];
} else { } else {
return "UNKNOWN_ERROR"; return "UNKNOWN_ERROR";

View file

@ -67,7 +67,7 @@ int main() {
{ {
TestCase my_test("Olm decrypt test"); TestCase my_test("Olm decrypt test");
for (int i = 0; i < sizeof(test_cases)/ sizeof(const char *); ++i) { for (unsigned int i = 0; i < sizeof(test_cases)/ sizeof(const char *); ++i) {
decrypt_case(0, test_cases[i]); decrypt_case(0, test_cases[i]);
} }

View file

@ -195,7 +195,7 @@ std::uint8_t random[] = "This is a random 32 byte string";
for (unsigned i = 0; i < 8; ++i) { for (unsigned i = 0; i < 8; ++i) {
{ {
std::uint8_t msg[alice.encrypt_output_length(sizeof(plaintext))]; std::uint8_t msg[alice.encrypt_output_length(sizeof(plaintext))];
std::uint8_t encrypt_length = alice.encrypt( alice.encrypt(
plaintext, 15, random, 32, msg, sizeof(msg) plaintext, 15, random, 32, msg, sizeof(msg)
); );
std::uint8_t output[bob.decrypt_max_plaintext_length(msg, sizeof(msg))]; std::uint8_t output[bob.decrypt_max_plaintext_length(msg, sizeof(msg))];
@ -206,7 +206,7 @@ for (unsigned i = 0; i < 8; ++i) {
random[31]++; random[31]++;
{ {
std::uint8_t msg[bob.encrypt_output_length(sizeof(plaintext))]; std::uint8_t msg[bob.encrypt_output_length(sizeof(plaintext))];
std::uint8_t encrypt_length = bob.encrypt( bob.encrypt(
plaintext, 15, random, 32, msg, sizeof(msg) plaintext, 15, random, 32, msg, sizeof(msg)
); );
std::uint8_t output[alice.decrypt_max_plaintext_length(msg, sizeof(msg))]; std::uint8_t output[alice.decrypt_max_plaintext_length(msg, sizeof(msg))];