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
+5
-4
@@ -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,
|
||||||
@@ -21153,8 +21154,8 @@ void mg_tls_init(struct mg_connection *c, const struct mg_tls_opts *opts) {
|
|||||||
mg_error(c, "hostname too long");
|
mg_error(c, "hostname too long");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memcpy(tls->hostname, opts->name.buf, opts->name.len);
|
strncpy((char *) tls->hostname, opts->name.buf, sizeof(tls->hostname) - 1);
|
||||||
tls->hostname[opts->name.len] = '\0';
|
tls->hostname[opts->name.len] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// server CA certificate; parse PEM [bundle] or DER
|
// server CA certificate; parse PEM [bundle] or DER
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
+2
-2
@@ -2748,8 +2748,8 @@ void mg_tls_init(struct mg_connection *c, const struct mg_tls_opts *opts) {
|
|||||||
mg_error(c, "hostname too long");
|
mg_error(c, "hostname too long");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memcpy(tls->hostname, opts->name.buf, opts->name.len);
|
strncpy((char *) tls->hostname, opts->name.buf, sizeof(tls->hostname) - 1);
|
||||||
tls->hostname[opts->name.len] = '\0';
|
tls->hostname[opts->name.len] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// server CA certificate; parse PEM [bundle] or DER
|
// server CA certificate; parse PEM [bundle] or DER
|
||||||
|
|||||||
Reference in new issue
Block a user