2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

[master] truncate logged rdata if too long

3490.	[bug]		When logging RDATA during update, truncate if it's
                        too long. [RT #32365]

cherry picked from:
        commit 16ddb566e5a5b57bf925adef2b5543dddc1de49b
        commit cd97e0c23b09f38aac49aabab66ee13c68b7a3f3
        commit d087fa982649c081d58c5bb16e63da3428e2b89d
        commit d0795bdffef57612dd7654ffd09c9f4216eee2c8
This commit is contained in:
Evan Hunt
2013-02-20 13:54:52 -08:00
parent 9d8985bea9
commit 2425d8bb7c
6 changed files with 37 additions and 11 deletions

View File

@@ -2859,22 +2859,30 @@ update_action(isc_task_t *task, isc_event_t *event) {
if (isc_log_wouldlog(ns_g_lctx, LOGLEVEL_PROTOCOL)) {
char namestr[DNS_NAME_FORMATSIZE];
char typestr[DNS_RDATATYPE_FORMATSIZE];
char rdstr[4096];
char rdstr[2048];
isc_buffer_t buf;
isc_region_t r;
int len = 0;
const char *truncated = "";
dns_name_format(name, namestr, sizeof(namestr));
dns_rdatatype_format(rdata.type, typestr,
sizeof(typestr));
isc_buffer_init(&buf, rdstr, sizeof(rdstr));
result = dns_rdata_totext(&rdata, NULL, &buf);
isc_buffer_usedregion(&buf, &r);
if (result == ISC_R_SUCCESS)
len = r.length;
if (result == ISC_R_NOSPACE) {
len = (int)isc_buffer_usedlength(&buf);
truncated = " [TRUNCATED]";
} else if (result != ISC_R_SUCCESS) {
snprintf(rdstr, sizeof(rdstr), "[dns_"
"rdata_totext failed: %s]",
dns_result_totext(result));
len = strlen(rdstr);
} else
len = (int)isc_buffer_usedlength(&buf);
update_log(client, zone, LOGLEVEL_PROTOCOL,
"adding an RR at '%s' %s %.*s",
namestr, typestr, len,
(char *) r.base);
"adding an RR at '%s' %s %.*s%s",
namestr, typestr, len, rdstr,
truncated);
}
/* Prepare the affected RRset for the addition. */