diff --git a/src/aead.c b/src/aead.c index a147f7be..2493fb43 100644 --- a/src/aead.c +++ b/src/aead.c @@ -505,7 +505,7 @@ aead_chunk_encrypt(cipher_ctx_t *ctx, uint8_t *p, uint8_t *c, uint8_t *n, int err; size_t clen; uint8_t len_buf[CHUNK_SIZE_LEN]; - uint16_t t = ntohs((plen + tlen) & CHUNK_SIZE_MASK); + uint16_t t = htons((plen + tlen) & CHUNK_SIZE_MASK); memcpy(len_buf, &t, CHUNK_SIZE_LEN); clen = CHUNK_SIZE_LEN + tlen; @@ -599,7 +599,7 @@ aead_chunk_decrypt(cipher_ctx_t *ctx, uint8_t *p, uint8_t *c, uint8_t *n, return CRYPTO_ERROR; assert(*plen == CHUNK_SIZE_LEN); - mlen = htons(*(uint16_t *)len_buf); + mlen = ntohs(*(uint16_t *)len_buf); mlen = mlen & CHUNK_SIZE_MASK; size_t chunk_len = tlen + CHUNK_SIZE_LEN + mlen; diff --git a/src/server.c b/src/server.c index 7bf2e612..44dc34ed 100644 --- a/src/server.c +++ b/src/server.c @@ -1627,7 +1627,11 @@ main(int argc, char **argv) struct ev_loop *loop = EV_DEFAULT; // setup udns - resolv_init(loop, nameservers, nameserver_num, ipv6first); + if (nameserver_num == 0) { + resolv_init(loop, NULL, 0, ipv6first); + } else { + resolv_init(loop, nameservers, nameserver_num, ipv6first); + } for (int i = 0; i < nameserver_num; i++) LOGI("using nameserver: %s", nameservers[i]);