mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-17 19:30:36 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9322227886 |
No files matched your search
+3
-2
@@ -2146,12 +2146,13 @@ bool mg_dns_parse(const uint8_t *buf, size_t len, struct mg_dns_message *dm) {
|
|||||||
dm->txnid = mg_ntohs(h->txnid);
|
dm->txnid = mg_ntohs(h->txnid);
|
||||||
is_response = mg_ntohs(h->flags) & 0x8000;
|
is_response = mg_ntohs(h->flags) & 0x8000;
|
||||||
|
|
||||||
for (i = 0; i < mg_ntohs(h->num_questions); i++) {
|
for (i = 0; i < mg_ntohs(h->num_questions); i++) { // advance past queries
|
||||||
if ((n = mg_dns_parse_rr(buf, len, ofs, true, &rr)) == 0) return false;
|
if ((n = mg_dns_parse_rr(buf, len, ofs, true, &rr)) == 0) return false;
|
||||||
// MG_INFO(("Q %lu %lu %hu/%hu", ofs, n, rr.atype, rr.aclass));
|
// MG_INFO(("Q %lu %lu %hu/%hu", ofs, n, rr.atype, rr.aclass));
|
||||||
|
dm->addr.is_ip6 = (rr.atype == MG_DNS_RTYPE_AAAA);
|
||||||
mg_dns_parse_name(buf, len, ofs, dm->name, sizeof(dm->name));
|
mg_dns_parse_name(buf, len, ofs, dm->name, sizeof(dm->name));
|
||||||
ofs += n;
|
ofs += n;
|
||||||
}
|
} // on unresolved responses, we got the name and query type, at least
|
||||||
|
|
||||||
if (!is_response) {
|
if (!is_response) {
|
||||||
// For queries, there is no need to parse the answers. In this way,
|
// For queries, there is no need to parse the answers. In this way,
|
||||||
|
|||||||
@@ -136,12 +136,13 @@ bool mg_dns_parse(const uint8_t *buf, size_t len, struct mg_dns_message *dm) {
|
|||||||
dm->txnid = mg_ntohs(h->txnid);
|
dm->txnid = mg_ntohs(h->txnid);
|
||||||
is_response = mg_ntohs(h->flags) & 0x8000;
|
is_response = mg_ntohs(h->flags) & 0x8000;
|
||||||
|
|
||||||
for (i = 0; i < mg_ntohs(h->num_questions); i++) {
|
for (i = 0; i < mg_ntohs(h->num_questions); i++) { // advance past queries
|
||||||
if ((n = mg_dns_parse_rr(buf, len, ofs, true, &rr)) == 0) return false;
|
if ((n = mg_dns_parse_rr(buf, len, ofs, true, &rr)) == 0) return false;
|
||||||
// MG_INFO(("Q %lu %lu %hu/%hu", ofs, n, rr.atype, rr.aclass));
|
// MG_INFO(("Q %lu %lu %hu/%hu", ofs, n, rr.atype, rr.aclass));
|
||||||
|
dm->addr.is_ip6 = (rr.atype == MG_DNS_RTYPE_AAAA);
|
||||||
mg_dns_parse_name(buf, len, ofs, dm->name, sizeof(dm->name));
|
mg_dns_parse_name(buf, len, ofs, dm->name, sizeof(dm->name));
|
||||||
ofs += n;
|
ofs += n;
|
||||||
}
|
} // on unresolved responses, we got the name and query type, at least
|
||||||
|
|
||||||
if (!is_response) {
|
if (!is_response) {
|
||||||
// For queries, there is no need to parse the answers. In this way,
|
// For queries, there is no need to parse the answers. In this way,
|
||||||
|
|||||||
+4
-4
@@ -2762,9 +2762,8 @@ void mg_tls_init(struct mg_connection *c, const struct mg_tls_opts *opts) {
|
|||||||
tls->ca_bundle_der = all_certs;
|
tls->ca_bundle_der = all_certs;
|
||||||
MG_VERBOSE(("%d-cert bundle", cert_count));
|
MG_VERBOSE(("%d-cert bundle", cert_count));
|
||||||
} else if (cert_count > 0) {
|
} else if (cert_count > 0) {
|
||||||
int i;
|
tls->ca_der.buf = all_certs[0].buf;
|
||||||
tls->ca_der = all_certs[0];
|
tls->ca_der.len = all_certs[0].len;
|
||||||
for (i = 1; i < cert_count; i++) mg_free((void *) all_certs[i].buf);
|
|
||||||
mg_free(all_certs);
|
mg_free(all_certs);
|
||||||
} else { // parse again for a possible DER (or a truncated begin string)
|
} else { // parse again for a possible DER (or a truncated begin string)
|
||||||
if (mg_parse_pem(opts->ca, mg_str_s("CERTIFICATE"), &tls->ca_der) < 0) {
|
if (mg_parse_pem(opts->ca, mg_str_s("CERTIFICATE"), &tls->ca_der) < 0) {
|
||||||
@@ -2790,7 +2789,8 @@ void mg_tls_init(struct mg_connection *c, const struct mg_tls_opts *opts) {
|
|||||||
int cert_count = mg_parse_pem_certs(opts->cert, &all_certs);
|
int cert_count = mg_parse_pem_certs(opts->cert, &all_certs);
|
||||||
|
|
||||||
if (cert_count > 0) {
|
if (cert_count > 0) {
|
||||||
tls->cert_der = all_certs[0];
|
tls->cert_der.buf = all_certs[0].buf;
|
||||||
|
tls->cert_der.len = all_certs[0].len;
|
||||||
if (cert_count > 1) {
|
if (cert_count > 1) {
|
||||||
tls->chain_len = (size_t) cert_count;
|
tls->chain_len = (size_t) cert_count;
|
||||||
tls->chain_der = all_certs;
|
tls->chain_der = all_certs;
|
||||||
|
|||||||
Reference in new issue
Block a user