Coverage Report

Created: 2026-01-10 06:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/bind9/lib/dns/rdata/generic/minfo_14.c
Line
Count
Source
1
/*
2
 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
3
 *
4
 * SPDX-License-Identifier: MPL-2.0
5
 *
6
 * This Source Code Form is subject to the terms of the Mozilla Public
7
 * License, v. 2.0. If a copy of the MPL was not distributed with this
8
 * file, you can obtain one at https://mozilla.org/MPL/2.0/.
9
 *
10
 * See the COPYRIGHT file distributed with this work for additional
11
 * information regarding copyright ownership.
12
 */
13
14
#ifndef RDATA_GENERIC_MINFO_14_C
15
#define RDATA_GENERIC_MINFO_14_C
16
17
13.2k
#define RRTYPE_MINFO_ATTRIBUTES (0)
18
19
static isc_result_t
20
1.56k
fromtext_minfo(ARGS_FROMTEXT) {
21
1.56k
  isc_token_t token;
22
1.56k
  dns_fixedname_t fn;
23
1.56k
  dns_name_t *name = dns_fixedname_initname(&fn);
24
1.56k
  isc_buffer_t buffer;
25
1.56k
  int i;
26
1.56k
  bool ok;
27
28
1.56k
  REQUIRE(type == dns_rdatatype_minfo);
29
30
1.56k
  UNUSED(type);
31
1.56k
  UNUSED(rdclass);
32
1.56k
  UNUSED(callbacks);
33
34
1.56k
  if (origin == NULL) {
35
7
    origin = dns_rootname;
36
7
  }
37
38
4.66k
  for (i = 0; i < 2; i++) {
39
3.11k
    RETERR(isc_lex_getmastertoken(lexer, &token,
40
3.11k
                isc_tokentype_string, false));
41
3.10k
    buffer_fromregion(&buffer, &token.value.as_region);
42
3.10k
    RETTOK(dns_name_fromtext(name, &buffer, origin, options));
43
3.10k
    RETTOK(dns_name_towire(name, NULL, target));
44
3.10k
    ok = true;
45
3.10k
    if ((options & DNS_RDATA_CHECKNAMES) != 0) {
46
0
      ok = dns_name_ismailbox(name);
47
0
    }
48
3.10k
    if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0) {
49
0
      RETTOK(DNS_R_BADNAME);
50
0
    }
51
3.10k
    if (!ok && callbacks != NULL) {
52
0
      warn_badname(name, lexer, callbacks);
53
0
    }
54
3.10k
  }
55
1.54k
  return ISC_R_SUCCESS;
56
1.56k
}
57
58
static isc_result_t
59
1.80k
totext_minfo(ARGS_TOTEXT) {
60
1.80k
  isc_region_t region;
61
1.80k
  dns_name_t rmail;
62
1.80k
  dns_name_t email;
63
1.80k
  dns_name_t prefix;
64
1.80k
  unsigned int opts;
65
66
1.80k
  REQUIRE(rdata->type == dns_rdatatype_minfo);
67
1.80k
  REQUIRE(rdata->length != 0);
68
69
1.80k
  dns_name_init(&rmail);
70
1.80k
  dns_name_init(&email);
71
1.80k
  dns_name_init(&prefix);
72
73
1.80k
  dns_rdata_toregion(rdata, &region);
74
75
1.80k
  dns_name_fromregion(&rmail, &region);
76
1.80k
  isc_region_consume(&region, rmail.length);
77
78
1.80k
  dns_name_fromregion(&email, &region);
79
1.80k
  isc_region_consume(&region, email.length);
80
81
1.80k
  opts = name_prefix(&rmail, tctx->origin, &prefix)
82
1.80k
           ? DNS_NAME_OMITFINALDOT
83
1.80k
           : 0;
84
1.80k
  RETERR(dns_name_totext(&prefix, opts, target));
85
86
1.80k
  RETERR(str_totext(" ", target));
87
88
1.80k
  opts = name_prefix(&email, tctx->origin, &prefix)
89
1.80k
           ? DNS_NAME_OMITFINALDOT
90
1.80k
           : 0;
91
1.80k
  return dns_name_totext(&prefix, opts, target);
92
1.80k
}
93
94
static isc_result_t
95
2.45k
fromwire_minfo(ARGS_FROMWIRE) {
96
2.45k
  dns_name_t rmail;
97
2.45k
  dns_name_t email;
98
99
2.45k
  REQUIRE(type == dns_rdatatype_minfo);
100
101
2.45k
  UNUSED(type);
102
2.45k
  UNUSED(rdclass);
103
104
2.45k
  dctx = dns_decompress_setpermitted(dctx, true);
105
106
2.45k
  dns_name_init(&rmail);
107
2.45k
  dns_name_init(&email);
108
109
2.45k
  RETERR(dns_name_fromwire(&rmail, source, dctx, target));
110
2.21k
  return dns_name_fromwire(&email, source, dctx, target);
111
2.45k
}
112
113
static isc_result_t
114
904
towire_minfo(ARGS_TOWIRE) {
115
904
  isc_region_t region;
116
904
  dns_name_t rmail;
117
904
  dns_name_t email;
118
119
904
  REQUIRE(rdata->type == dns_rdatatype_minfo);
120
904
  REQUIRE(rdata->length != 0);
121
122
904
  dns_compress_setpermitted(cctx, true);
123
124
904
  dns_name_init(&rmail);
125
904
  dns_name_init(&email);
126
127
904
  dns_rdata_toregion(rdata, &region);
128
129
904
  dns_name_fromregion(&rmail, &region);
130
904
  isc_region_consume(&region, name_length(&rmail));
131
132
904
  RETERR(dns_name_towire(&rmail, cctx, target));
133
134
903
  dns_name_fromregion(&rmail, &region);
135
903
  isc_region_consume(&region, rmail.length);
136
137
903
  return dns_name_towire(&rmail, cctx, target);
138
904
}
139
140
static int
141
139k
compare_minfo(ARGS_COMPARE) {
142
139k
  isc_region_t region1;
143
139k
  isc_region_t region2;
144
139k
  dns_name_t name1;
145
139k
  dns_name_t name2;
146
139k
  int order;
147
148
139k
  REQUIRE(rdata1->type == rdata2->type);
149
139k
  REQUIRE(rdata1->rdclass == rdata2->rdclass);
150
139k
  REQUIRE(rdata1->type == dns_rdatatype_minfo);
151
139k
  REQUIRE(rdata1->length != 0);
152
139k
  REQUIRE(rdata2->length != 0);
153
154
139k
  dns_name_init(&name1);
155
139k
  dns_name_init(&name2);
156
157
139k
  dns_rdata_toregion(rdata1, &region1);
158
139k
  dns_rdata_toregion(rdata2, &region2);
159
160
139k
  dns_name_fromregion(&name1, &region1);
161
139k
  dns_name_fromregion(&name2, &region2);
162
163
139k
  order = dns_name_rdatacompare(&name1, &name2);
164
139k
  if (order != 0) {
165
138k
    return order;
166
138k
  }
167
168
1.15k
  isc_region_consume(&region1, name_length(&name1));
169
1.15k
  isc_region_consume(&region2, name_length(&name2));
170
171
1.15k
  dns_name_init(&name1);
172
1.15k
  dns_name_init(&name2);
173
174
1.15k
  dns_name_fromregion(&name1, &region1);
175
1.15k
  dns_name_fromregion(&name2, &region2);
176
177
1.15k
  order = dns_name_rdatacompare(&name1, &name2);
178
1.15k
  return order;
179
139k
}
180
181
static isc_result_t
182
0
fromstruct_minfo(ARGS_FROMSTRUCT) {
183
0
  dns_rdata_minfo_t *minfo = source;
184
0
  isc_region_t region;
185
186
0
  REQUIRE(type == dns_rdatatype_minfo);
187
0
  REQUIRE(minfo != NULL);
188
0
  REQUIRE(minfo->common.rdtype == type);
189
0
  REQUIRE(minfo->common.rdclass == rdclass);
190
191
0
  UNUSED(type);
192
0
  UNUSED(rdclass);
193
194
0
  dns_name_toregion(&minfo->rmailbox, &region);
195
0
  RETERR(isc_buffer_copyregion(target, &region));
196
0
  dns_name_toregion(&minfo->emailbox, &region);
197
0
  return isc_buffer_copyregion(target, &region);
198
0
}
199
200
static isc_result_t
201
0
tostruct_minfo(ARGS_TOSTRUCT) {
202
0
  dns_rdata_minfo_t *minfo = target;
203
0
  isc_region_t region;
204
0
  dns_name_t name;
205
206
0
  REQUIRE(rdata->type == dns_rdatatype_minfo);
207
0
  REQUIRE(minfo != NULL);
208
0
  REQUIRE(rdata->length != 0);
209
210
0
  DNS_RDATACOMMON_INIT(minfo, rdata->type, rdata->rdclass);
211
212
0
  dns_name_init(&name);
213
0
  dns_rdata_toregion(rdata, &region);
214
0
  dns_name_fromregion(&name, &region);
215
0
  dns_name_init(&minfo->rmailbox);
216
0
  name_duporclone(&name, mctx, &minfo->rmailbox);
217
0
  isc_region_consume(&region, name_length(&name));
218
219
0
  dns_name_fromregion(&name, &region);
220
0
  dns_name_init(&minfo->emailbox);
221
0
  name_duporclone(&name, mctx, &minfo->emailbox);
222
0
  minfo->mctx = mctx;
223
0
  return ISC_R_SUCCESS;
224
0
}
225
226
static void
227
0
freestruct_minfo(ARGS_FREESTRUCT) {
228
0
  dns_rdata_minfo_t *minfo = source;
229
230
0
  REQUIRE(minfo != NULL);
231
0
  REQUIRE(minfo->common.rdtype == dns_rdatatype_minfo);
232
233
0
  if (minfo->mctx == NULL) {
234
0
    return;
235
0
  }
236
237
0
  dns_name_free(&minfo->rmailbox, minfo->mctx);
238
0
  dns_name_free(&minfo->emailbox, minfo->mctx);
239
0
  minfo->mctx = NULL;
240
0
}
241
242
static isc_result_t
243
0
additionaldata_minfo(ARGS_ADDLDATA) {
244
0
  REQUIRE(rdata->type == dns_rdatatype_minfo);
245
246
0
  UNUSED(rdata);
247
0
  UNUSED(owner);
248
0
  UNUSED(add);
249
0
  UNUSED(arg);
250
251
0
  return ISC_R_SUCCESS;
252
0
}
253
254
static isc_result_t
255
0
digest_minfo(ARGS_DIGEST) {
256
0
  isc_region_t r;
257
0
  dns_name_t name;
258
259
0
  REQUIRE(rdata->type == dns_rdatatype_minfo);
260
261
0
  dns_rdata_toregion(rdata, &r);
262
0
  dns_name_init(&name);
263
0
  dns_name_fromregion(&name, &r);
264
0
  RETERR(dns_name_digest(&name, digest, arg));
265
0
  isc_region_consume(&r, name_length(&name));
266
0
  dns_name_init(&name);
267
0
  dns_name_fromregion(&name, &r);
268
269
0
  return dns_name_digest(&name, digest, arg);
270
0
}
271
272
static bool
273
0
checkowner_minfo(ARGS_CHECKOWNER) {
274
0
  REQUIRE(type == dns_rdatatype_minfo);
275
276
0
  UNUSED(name);
277
0
  UNUSED(type);
278
0
  UNUSED(rdclass);
279
0
  UNUSED(wildcard);
280
281
0
  return true;
282
0
}
283
284
static bool
285
0
checknames_minfo(ARGS_CHECKNAMES) {
286
0
  isc_region_t region;
287
0
  dns_name_t name;
288
289
0
  REQUIRE(rdata->type == dns_rdatatype_minfo);
290
291
0
  UNUSED(owner);
292
293
0
  dns_rdata_toregion(rdata, &region);
294
0
  dns_name_init(&name);
295
0
  dns_name_fromregion(&name, &region);
296
0
  if (!dns_name_ismailbox(&name)) {
297
0
    if (bad != NULL) {
298
0
      dns_name_clone(&name, bad);
299
0
    }
300
0
    return false;
301
0
  }
302
0
  isc_region_consume(&region, name_length(&name));
303
0
  dns_name_fromregion(&name, &region);
304
0
  if (!dns_name_ismailbox(&name)) {
305
0
    if (bad != NULL) {
306
0
      dns_name_clone(&name, bad);
307
0
    }
308
0
    return false;
309
0
  }
310
0
  return true;
311
0
}
312
313
static int
314
0
casecompare_minfo(ARGS_COMPARE) {
315
0
  return compare_minfo(rdata1, rdata2);
316
0
}
317
318
#endif /* RDATA_GENERIC_MINFO_14_C */