Merge branch 'fix-hash' into add-message
This commit is contained in:
commit
fd623ee484
@ -17,7 +17,10 @@ void hash_data(pub_data *data, unsigned char *buf) {
|
||||
|
||||
// Hash every data contained in data_list then return a network hash
|
||||
void hash_network(list *data_list, unsigned char *buf) {
|
||||
unsigned char *concat = (unsigned char*) malloc(0);
|
||||
// Get list length to initialize concat buffer
|
||||
int concat_len = len_list(data_list) * 16;
|
||||
unsigned char *concat = (unsigned char*) malloc(concat_len);
|
||||
|
||||
unsigned char hash[SHA256_DIGEST_LENGTH];
|
||||
int totlen = 0;
|
||||
list *tmp = data_list;
|
||||
@ -55,6 +58,5 @@ void concat_data(pub_data *data, unsigned char *buf) {
|
||||
|
||||
// Concat hash2 to hash1 (hash1 is modified)
|
||||
void concat_hash(unsigned char *hash1, unsigned char *hash2, size_t size) {
|
||||
hash1 = (unsigned char*) realloc(hash1, size + 16);
|
||||
memcpy(hash1+size, hash2, 16);
|
||||
}
|
||||
|
10
src/node.c
10
src/node.c
@ -192,7 +192,7 @@ pub_data *get_data(int64_t id) {
|
||||
|
||||
while(tmp != NULL) {
|
||||
data = (pub_data*) tmp->data;
|
||||
|
||||
tmp = tmp->next;
|
||||
if(data->id == id)
|
||||
return data;
|
||||
}
|
||||
@ -487,7 +487,9 @@ int send_packet(char *packet_buff, int16_t length, struct sockaddr_in6 *dest, in
|
||||
((packet*) packet_buff)->length = htons(((packet*) packet_buff)->length);
|
||||
|
||||
// Vectorized buffer
|
||||
struct iovec vec_buff = {.iov_len = length + 4, .iov_base = packet_buff};
|
||||
struct iovec vec_buff[1];
|
||||
vec_buff[0].iov_len = length + 4;
|
||||
vec_buff[0].iov_base = packet_buff;
|
||||
|
||||
int error_while_sending = 0;
|
||||
|
||||
@ -495,7 +497,7 @@ int send_packet(char *packet_buff, int16_t length, struct sockaddr_in6 *dest, in
|
||||
struct msghdr packet_tlv_send_out = {
|
||||
.msg_name = dest,
|
||||
.msg_namelen = sizeof(struct sockaddr_in6),
|
||||
.msg_iov = &vec_buff,
|
||||
.msg_iov = vec_buff,
|
||||
.msg_iovlen = 1 // We have only one iovec buffer. But if we had 2, we would write 2.
|
||||
};
|
||||
|
||||
@ -970,7 +972,7 @@ int work_with_tlvs(char * data, int16_t total_packet_len, struct sockaddr_in6 *s
|
||||
cur_tlv.warning = (warning*) (data + pos);
|
||||
|
||||
// Print exactly new_tlv.length characters from new_tlv.message
|
||||
sprintf(warn, "\x1b[31m>> WARNING:\n%%.%ds \x1b[0m", cur_tlv.warning->length + 1);
|
||||
sprintf(warn, ">> WARNING:\n%%.%ds", cur_tlv.warning->length + 1);
|
||||
printf(warn, cur_tlv.warning->message);
|
||||
|
||||
// The position is updated
|
||||
|
Loading…
Reference in New Issue
Block a user