diff options
| author | Dennis Brentjes <d.brentjes@gmail.com> | 2017-02-26 20:47:52 +0100 |
|---|---|---|
| committer | Dennis Brentjes <d.brentjes@gmail.com> | 2017-02-26 21:30:42 +0100 |
| commit | b989f4381c77cd95ee06e600e264907991bbd461 (patch) | |
| tree | bf050bbb6a0efda4702ded241702bbe7aedc2cab | |
| parent | 83c7247c0991b1988c2f505cf8449f4afa6b806d (diff) | |
| download | cmix-b989f4381c77cd95ee06e600e264907991bbd461.tar.gz cmix-b989f4381c77cd95ee06e600e264907991bbd461.tar.bz2 cmix-b989f4381c77cd95ee06e600e264907991bbd461.zip | |
Fixes a bug which would crash the server when an ID started with 0x00.
| -rw-r--r-- | libcmix-crypto/ed25519/gcrypt/gcrypt_ed25519.c | 17 | ||||
| -rw-r--r-- | node/node_node.cpp | 9 | ||||
| -rwxr-xr-x | run.sh | 23 |
3 files changed, 22 insertions, 27 deletions
diff --git a/libcmix-crypto/ed25519/gcrypt/gcrypt_ed25519.c b/libcmix-crypto/ed25519/gcrypt/gcrypt_ed25519.c index 4839ce5..8807282 100644 --- a/libcmix-crypto/ed25519/gcrypt/gcrypt_ed25519.c +++ b/libcmix-crypto/ed25519/gcrypt/gcrypt_ed25519.c @@ -154,7 +154,7 @@ GroupElement DEF(message_to_element)(char const* buffer, size_t len, bool secure (void) secure; gcry_error_t error; - //assert(len == 31); + assert(len == 31); gcry_mpi_t mpi; gcry_mpi_scan(&mpi, GCRYMPI_FMT_USG, buffer, len, NULL); @@ -167,11 +167,16 @@ GroupElement DEF(message_to_element)(char const* buffer, size_t len, bool secure unsigned int count = 0; do { encoded_point[0] = 0x40; - - unsigned int byte_size = (unsigned) ceil(gcry_mpi_get_nbits(mpi) / 8.0); - //gcry_mpi_print(GCRYMPI_FMT_USG, (unsigned char*) encoded_point + 1 + (32 - byte_size), byte_size, NULL, mpi); - gcry_mpi_print(GCRYMPI_FMT_USG, (unsigned char*) encoded_point + 1, 32, NULL, mpi); + memset(encoded_point + 1, '\0', 32); + unsigned char* gcry_buffer; + size_t nr_written; + + gcry_mpi_aprint(GCRYMPI_FMT_USG, &gcry_buffer, &nr_written, mpi); + + memcpy(encoded_point + 1 + (nr_bytes - nr_written), gcry_buffer, nr_written); + gcry_free(gcry_buffer); + for(int i = 0; i < 16; i++) { char temp = encoded_point[i+1]; encoded_point[i+1] = encoded_point[32-i]; @@ -222,7 +227,7 @@ void DEF(element_to_message)(unsigned char** buffer, const GroupElement el) { size_t nr_written; gcry_mpi_aprint(GCRYMPI_FMT_USG, &buffer2, &nr_written, y); - memcpy(*buffer, buffer2, mes_len); + memcpy(*buffer + (mes_len - nr_written), buffer2, nr_written); gcry_free(buffer2); gcry_mpi_release(y); diff --git a/node/node_node.cpp b/node/node_node.cpp index 0bac4b3..14e3604 100644 --- a/node/node_node.cpp +++ b/node/node_node.cpp @@ -491,12 +491,9 @@ void Node::handle_node_realpost(cmix_proto::RealPost const& realpost) { cmix_proto::Payload pay; pay.set_payload(payload, payload_len); - try { - clients.at(dest_s).async_send(pay); - } catch(...) { - exit(-1); - } - + + clients.at(dest_s).async_send(pay); + free(dest); free(payload); free(message); @@ -16,13 +16,14 @@ else tool="" fi +nr_clients=1 tmux new-session -s cmix -d tmux send-keys -t cmix:0 "cd ${build_dir} && LSAN_OPTIONS=report_objects=1 $tool statsd/statsd" Enter tmux new-window -t cmix:1 -tmux send-keys -t cmix:1 "cd ${build_dir} && LSAN_OPTIONS=report_objects=1 $tool node/node -f -m 5 -n node2.local:9201 -s localhost:9199 -a node1 -c ../certs/cert1.pem -k ../certs/key1.pem -d ../certs/dh.pem --certdir ../certs/" Enter +tmux send-keys -t cmix:1 "cd ${build_dir} && LSAN_OPTIONS=report_objects=1 $tool node/node -f -m ${nr_clients} -n node2.local:9201 -s localhost:9199 -a node1 -c ../certs/cert1.pem -k ../certs/key1.pem -d ../certs/dh.pem --certdir ../certs/" Enter tmux new-window -t cmix:2 tmux send-keys -t cmix:2 "cd ${build_dir} && LSAN_OPTIONS=report_objects=1 $tool node/node -p 9201 -n node3.local:9202 -s localhost:9199 -a node2 -c ../certs/cert2.pem -k ../certs/key2.pem -d ../certs/dh.pem --certdir ../certs/" Enter @@ -30,21 +31,13 @@ tmux send-keys -t cmix:2 "cd ${build_dir} && LSAN_OPTIONS=report_objects=1 $tool tmux new-window -t cmix:3 tmux send-keys -t cmix:3 "cd ${build_dir} && LSAN_OPTIONS=report_objects=1 $tool node/node -l -p 9202 -n node1.local:9200 -s localhost:9199 -a node3 -c ../certs/cert3.pem -k ../certs/key3.pem -d ../certs/dh.pem --certdir ../certs/" Enter -tmux new-window -t cmix:4 -tmux send-keys -t cmix:4 "cd ${build_dir} && LSAN_OPTIONS=report_objects=1 $tool client/client --certdir ../certs -n node1.local:9200 node2.local:9201 node3.local:9202" Enter - -tmux new-window -t cmix:5 -tmux send-keys -t cmix:5 "cd ${build_dir} && LSAN_OPTIONS=report_objects=1 $tool client/client --certdir ../certs -n node1.local:9200 node2.local:9201 node3.local:9202" Enter - -tmux new-window -t cmix:6 -tmux send-keys -t cmix:6 "cd ${build_dir} && LSAN_OPTIONS=report_objects=1 $tool client/client --certdir ../certs -n node1.local:9200 node2.local:9201 node3.local:9202" Enter - -tmux new-window -t cmix:7 -tmux send-keys -t cmix:7 "cd ${build_dir} && LSAN_OPTIONS=report_objects=1 $tool client/client --certdir ../certs -n node1.local:9200 node2.local:9201 node3.local:9202" Enter - -tmux new-window -t cmix:8 -tmux send-keys -t cmix:8 "cd ${build_dir} && LSAN_OPTIONS=report_objects=1 $tool client/client --certdir ../certs -n node1.local:9200 node2.local:9201 node3.local:9202" Enter +for i in $(seq 4 $((3+${nr_clients}))); +do + tmux new-window -t cmix:${i} + tmux send-keys -t cmix:${i} "cd ${build_dir} && LSAN_OPTIONS=report_objects=1 $tool client/client --certdir ../certs -n node1.local:9200 node2.local:9201 node3.local:9202" Enter +done +tmux select-window -t cmix:3 tmux attach tmux kill-session -t cmix |
