summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliuxueli <[email protected]>2024-11-15 11:03:10 +0800
committerliuxueli <[email protected]>2024-11-15 11:03:10 +0800
commit364c16835c90ee4e82153635a18fbc0e4f7cccd4 (patch)
tree598302c76a1c0c3e4980387a425f812428369a78
parent35d27b82e703a0e36b36d4d532527a79326c9257 (diff)
Bugfix: The ms/txt/null buffer ends with \0HEADv2.1.8master
-rw-r--r--src/dns.cpp8
-rw-r--r--test/pcap/nsec_10_1/nsec_result.json36
2 files changed, 23 insertions, 21 deletions
diff --git a/src/dns.cpp b/src/dns.cpp
index cf8c6d8..d8d5d6b 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -1606,7 +1606,7 @@ int get_one_resource_record(char *msg, char **ptr, dns_rr_t *rr, const char *en
*ptr += rr->rdlength;
break;
}
- len = MIN(DNS_MAX_NAME-1, rr->rdlength-2);/*size=1byte*/
+ len = MIN(DNS_MAX_NAME, rr->rdlength-2);/*size=1byte*/
memcpy(rr->rdata.mx.exchange, *ptr, len); /* error labels */
rr->rdata.mx.exchange[len]='\0';
*ptr += rr->rdlength-2;
@@ -1668,8 +1668,9 @@ int get_one_resource_record(char *msg, char **ptr, dns_rr_t *rr, const char *en
(*ptr)+=1;
break;
case DNS_TYPE_TXT:
- len = MIN(DNS_MAX_NAME-1, rr->rdlength-1);/*size=1byte*/
+ len = MIN(DNS_MAX_NAME, rr->rdlength-1);/*size=1byte*/
memcpy(rr->rdata.txt.txt, *ptr+1, len);
+ rr->rdata.txt.txt[len]='\0';
rr->rdata.txt.size = len;
*ptr += rr->rdlength;
break;
@@ -1686,8 +1687,9 @@ int get_one_resource_record(char *msg, char **ptr, dns_rr_t *rr, const char *en
}
break;
case DNS_TYPE_NULL:
- len = MIN(DNS_MAX_NAME-1, rr->rdlength-1); /*size=1byte*/
+ len = MIN(DNS_MAX_NAME, rr->rdlength-1); /*size=1byte*/
memcpy(rr->rdata.null.null, *ptr+1, len);
+ rr->rdata.null.null[len]='\0';
rr->rdata.null.size = len;
*ptr += rr->rdlength;
break;
diff --git a/test/pcap/nsec_10_1/nsec_result.json b/test/pcap/nsec_10_1/nsec_result.json
index 0f31d2f..8c22eeb 100644
--- a/test/pcap/nsec_10_1/nsec_result.json
+++ b/test/pcap/nsec_10_1/nsec_result.json
@@ -469,7 +469,7 @@
"class": 1,
"ttl": 99,
"rdlength": 14,
- "txt": "MS=ms95960309tion=6000569944866967d163c6c7e4c0c5c63ccfbabf",
+ "txt": "MS=ms95960309",
"size": 13
}, {
"name": "paypal.com",
@@ -477,7 +477,7 @@
"class": 1,
"ttl": 99,
"rdlength": 38,
- "txt": "yandex-verification: 73acb90f6a9abd76uapvYDGd2VtPARy1qq9ymN6",
+ "txt": "yandex-verification: 73acb90f6a9abd76",
"size": 37
}, {
"name": "paypal.com",
@@ -485,7 +485,7 @@
"class": 1,
"ttl": 99,
"rdlength": 69,
- "txt": "google-site-verification=Mfy_g_Azi4RuSGy1j4xdt9Rd11lTVk7pXIqqFs6OkkQfesYJErtGKylvfcfyfwrPD/wnv",
+ "txt": "google-site-verification=Mfy_g_Azi4RuSGy1j4xdt9Rd11lTVk7pXIqqFs6OkkQ",
"size": 68
}, {
"name": "paypal.com",
@@ -533,7 +533,7 @@
"class": 1,
"ttl": 99,
"rdlength": 46,
- "txt": "QuoVadis=e6fee6e2-ca5b-44fe-9e87-002e95088be51._spf.paypal.com include:3ph2._spf.paypal.com include:3ph3._spf.paypal.com include:3ph4._spf.paypal.com include:3ph5._spf.paypal.com include:aspmx.pardot.com ~all",
+ "txt": "QuoVadis=e6fee6e2-ca5b-44fe-9e87-002e95088be5",
"size": 45
}, {
"name": "paypal.com",
@@ -541,7 +541,7 @@
"class": 1,
"ttl": 99,
"rdlength": 61,
- "txt": "workplace-domain-verification=F7ezsH9uapvYDGd2VtPARy1qq9ymN62992b4bf61a4fa4837bfd9d600e33687f",
+ "txt": "workplace-domain-verification=F7ezsH9uapvYDGd2VtPARy1qq9ymN6",
"size": 60
}, {
"name": "paypal.com",
@@ -3151,7 +3151,7 @@
"class": 1,
"ttl": 99,
"rdlength": 94,
- "txt": "cisco-ci-domain-verification=572203ae596d1b2278c7807a35893712992b4bf61a4fa4837bfd9d600e33687fv",
+ "txt": "cisco-ci-domain-verification=572203ae596d1b2278c7807a35893712992b4bf61a4fa4837bfd9d600e33687f",
"size": 93
}, {
"name": "paypal.com",
@@ -3159,7 +3159,7 @@
"class": 1,
"ttl": 99,
"rdlength": 93,
- "txt": "adobe-idp-site-verification=11600efbec96c0e73dd8820cd33ca906ec4302aea4487d208a42a2b01806144cf",
+ "txt": "adobe-idp-site-verification=11600efbec96c0e73dd8820cd33ca906ec4302aea4487d208a42a2b01806144c",
"size": 92
}, {
"name": "paypal.com",
@@ -3167,7 +3167,7 @@
"class": 1,
"ttl": 99,
"rdlength": 14,
- "txt": "MS=ms95960309",
+ "txt": "MS=ms95960309",
"size": 13
}, {
"name": "paypal.com",
@@ -3199,7 +3199,7 @@
"class": 1,
"ttl": 99,
"rdlength": 61,
- "txt": "workplace-domain-verification=F7ezsH9uapvYDGd2VtPARy1qq9ymN6om include:3ph2._spf.paypal.com include:3ph3._spf.paypal.com include:3ph4._spf.paypal.com include:3ph5._spf.paypal.com include:aspmx.pardot.com ~all",
+ "txt": "workplace-domain-verification=F7ezsH9uapvYDGd2VtPARy1qq9ymN6",
"size": 60
}, {
"name": "paypal.com",
@@ -3207,7 +3207,7 @@
"class": 1,
"ttl": 99,
"rdlength": 38,
- "txt": "yandex-verification: 73acb90f6a9abd76uapvYDGd2VtPARy1qq9ymN62992b4bf61a4fa4837bfd9d600e33687f",
+ "txt": "yandex-verification: 73acb90f6a9abd76",
"size": 37
}, {
"name": "paypal.com",
@@ -3223,7 +3223,7 @@
"class": 1,
"ttl": 99,
"rdlength": 43,
- "txt": "apple-domain-verification=NwnxXMTYI88HNeXre73dd8820cd33ca906ec4302aea4487d208a42a2b01806144c",
+ "txt": "apple-domain-verification=NwnxXMTYI88HNeXr",
"size": 42
}, {
"name": "paypal.com",
@@ -3585,7 +3585,7 @@
"class": 1,
"ttl": 99,
"rdlength": 59,
- "txt": "miro-verification=6000569944866967d163c6c7e4c0c5c63ccfbabfIqqFs6OkkQ",
+ "txt": "miro-verification=6000569944866967d163c6c7e4c0c5c63ccfbabf",
"size": 58
}, {
"name": "paypal.com",
@@ -3593,7 +3593,7 @@
"class": 1,
"ttl": 99,
"rdlength": 69,
- "txt": "google-site-verification=Mfy_g_Azi4RuSGy1j4xdt9Rd11lTVk7pXIqqFs6OkkQ61a4fa4837bfd9d600e33687fv",
+ "txt": "google-site-verification=Mfy_g_Azi4RuSGy1j4xdt9Rd11lTVk7pXIqqFs6OkkQ",
"size": 68
}, {
"name": "paypal.com",
@@ -3601,7 +3601,7 @@
"class": 1,
"ttl": 99,
"rdlength": 38,
- "txt": "yandex-verification: 73acb90f6a9abd76c96c0e73dd8820cd33ca906ec4302aea4487d208a42a2b01806144cf",
+ "txt": "yandex-verification: 73acb90f6a9abd76",
"size": 37
}, {
"name": "paypal.com",
@@ -3609,7 +3609,7 @@
"class": 1,
"ttl": 99,
"rdlength": 14,
- "txt": "MS=ms95960309",
+ "txt": "MS=ms95960309",
"size": 13
}, {
"name": "paypal.com",
@@ -3641,7 +3641,7 @@
"class": 1,
"ttl": 99,
"rdlength": 94,
- "txt": "cisco-ci-domain-verification=572203ae596d1b2278c7807a35893712992b4bf61a4fa4837bfd9d600e33687fnclude:3ph3._spf.paypal.com include:3ph4._spf.paypal.com include:3ph5._spf.paypal.com include:aspmx.pardot.com ~all",
+ "txt": "cisco-ci-domain-verification=572203ae596d1b2278c7807a35893712992b4bf61a4fa4837bfd9d600e33687f",
"size": 93
}, {
"name": "paypal.com",
@@ -3649,7 +3649,7 @@
"class": 1,
"ttl": 99,
"rdlength": 46,
- "txt": "QuoVadis=e6fee6e2-ca5b-44fe-9e87-002e95088be52VtPARy1qq9ymN62992b4bf61a4fa4837bfd9d600e33687f",
+ "txt": "QuoVadis=e6fee6e2-ca5b-44fe-9e87-002e95088be5",
"size": 45
}, {
"name": "paypal.com",
@@ -3665,7 +3665,7 @@
"class": 1,
"ttl": 99,
"rdlength": 43,
- "txt": "apple-domain-verification=NwnxXMTYI88HNeXre73dd8820cd33ca906ec4302aea4487d208a42a2b01806144c",
+ "txt": "apple-domain-verification=NwnxXMTYI88HNeXr",
"size": 42
}, {
"name": "paypal.com",