diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-08-31 19:12:19 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-08-31 20:04:16 +0100 |
commit | 633da98ae69866efb195e00d9a3a22ace6bada66 (patch) | |
tree | 875535f3d2257c4ea5bb97a553b2f1beab4a1590 /toxdns/toxdns.c | |
parent | 6356eb4e4fe407fa7870f2a685d0d08b5c2ec5bb (diff) |
Add braces to all if statements.
Diffstat (limited to 'toxdns/toxdns.c')
-rw-r--r-- | toxdns/toxdns.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/toxdns/toxdns.c b/toxdns/toxdns.c index 7b07fa16..65da4908 100644 --- a/toxdns/toxdns.c +++ b/toxdns/toxdns.c | |||
@@ -70,8 +70,9 @@ void *tox_dns3_new(uint8_t *server_public_key) | |||
70 | { | 70 | { |
71 | DNS_Object *d = malloc(sizeof(DNS_Object)); | 71 | DNS_Object *d = malloc(sizeof(DNS_Object)); |
72 | 72 | ||
73 | if (d == NULL) | 73 | if (d == NULL) { |
74 | return NULL; | 74 | return NULL; |
75 | } | ||
75 | 76 | ||
76 | memcpy(d->server_public_key, server_public_key, crypto_box_PUBLICKEYBYTES); | 77 | memcpy(d->server_public_key, server_public_key, crypto_box_PUBLICKEYBYTES); |
77 | dns_new_temp_keys(d); | 78 | dns_new_temp_keys(d); |
@@ -106,8 +107,9 @@ int tox_generate_dns3_string(void *dns3_object, uint8_t *string, uint16_t string | |||
106 | int end_len = ((base * 8) / 5) + (base / DOT_INTERVAL) + !!(base % 5); | 107 | int end_len = ((base * 8) / 5) + (base / DOT_INTERVAL) + !!(base % 5); |
107 | end_len -= !(base % DOT_INTERVAL); | 108 | end_len -= !(base % DOT_INTERVAL); |
108 | 109 | ||
109 | if (end_len > string_max_len) | 110 | if (end_len > string_max_len) { |
110 | return -1; | 111 | return -1; |
112 | } | ||
111 | 113 | ||
112 | DNS_Object *d = dns3_object; | 114 | DNS_Object *d = dns3_object; |
113 | uint8_t buffer[1024]; | 115 | uint8_t buffer[1024]; |
@@ -118,8 +120,9 @@ int tox_generate_dns3_string(void *dns3_object, uint8_t *string, uint16_t string | |||
118 | int len = encrypt_data_symmetric(d->shared_key, nonce, name, name_len, | 120 | int len = encrypt_data_symmetric(d->shared_key, nonce, name, name_len, |
119 | buffer + sizeof(uint32_t) + crypto_box_PUBLICKEYBYTES); | 121 | buffer + sizeof(uint32_t) + crypto_box_PUBLICKEYBYTES); |
120 | 122 | ||
121 | if (len == -1) | 123 | if (len == -1) { |
122 | return -1; | 124 | return -1; |
125 | } | ||
123 | 126 | ||
124 | int total_len = len + sizeof(uint32_t) + crypto_box_PUBLICKEYBYTES; | 127 | int total_len = len + sizeof(uint32_t) + crypto_box_PUBLICKEYBYTES; |
125 | uint8_t *buff = buffer, *old_str = string; | 128 | uint8_t *buff = buffer, *old_str = string; |
@@ -201,8 +204,9 @@ int tox_decrypt_dns3_TXT(void *dns3_object, uint8_t *tox_id, uint8_t *id_record, | |||
201 | { | 204 | { |
202 | DNS_Object *d = dns3_object; | 205 | DNS_Object *d = dns3_object; |
203 | 206 | ||
204 | if (id_record_len != 87) | 207 | if (id_record_len != 87) { |
205 | return -1; | 208 | return -1; |
209 | } | ||
206 | 210 | ||
207 | /*if (id_record_len > 255 || id_record_len <= (sizeof(uint32_t) + crypto_box_MACBYTES)) | 211 | /*if (id_record_len > 255 || id_record_len <= (sizeof(uint32_t) + crypto_box_MACBYTES)) |
208 | return -1;*/ | 212 | return -1;*/ |
@@ -213,16 +217,18 @@ int tox_decrypt_dns3_TXT(void *dns3_object, uint8_t *tox_id, uint8_t *id_record, | |||
213 | uint8_t data[id_record_len]; | 217 | uint8_t data[id_record_len]; |
214 | int length = decode(data, id_record_null); | 218 | int length = decode(data, id_record_null); |
215 | 219 | ||
216 | if (length == -1) | 220 | if (length == -1) { |
217 | return -1; | 221 | return -1; |
222 | } | ||
218 | 223 | ||
219 | uint8_t nonce[crypto_box_NONCEBYTES] = {0}; | 224 | uint8_t nonce[crypto_box_NONCEBYTES] = {0}; |
220 | memcpy(nonce, &request_id, sizeof(uint32_t)); | 225 | memcpy(nonce, &request_id, sizeof(uint32_t)); |
221 | nonce[sizeof(uint32_t)] = 1; | 226 | nonce[sizeof(uint32_t)] = 1; |
222 | int len = decrypt_data_symmetric(d->shared_key, nonce, data, length, tox_id); | 227 | int len = decrypt_data_symmetric(d->shared_key, nonce, data, length, tox_id); |
223 | 228 | ||
224 | if (len != FRIEND_ADDRESS_SIZE) | 229 | if (len != FRIEND_ADDRESS_SIZE) { |
225 | return -1; | 230 | return -1; |
231 | } | ||
226 | 232 | ||
227 | return 0; | 233 | return 0; |
228 | } | 234 | } |