Skip to content

Commit f46acec

Browse files
committed
- For #1189, homogenize the input buffer size for dname_str().
1 parent 1cd2fb3 commit f46acec

26 files changed

+110
-105
lines changed

daemon/cachedump.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ int print_deleg_lookup(RES* ssl, struct worker* worker, uint8_t* nm,
836836
struct delegpt* dp;
837837
struct dns_msg* msg;
838838
struct regional* region = worker->scratchpad;
839-
char b[260];
839+
char b[LDNS_MAX_DOMAINLEN];
840840
struct query_info qinfo;
841841
struct iter_hints_stub* stub;
842842
int nolock = 0;

daemon/remote.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -2141,7 +2141,7 @@ static int
21412141
ssl_print_name_dp(RES* ssl, const char* str, uint8_t* nm, uint16_t dclass,
21422142
struct delegpt* dp)
21432143
{
2144-
char buf[257];
2144+
char buf[LDNS_MAX_DOMAINLEN];
21452145
struct delegpt_ns* ns;
21462146
struct delegpt_addr* a;
21472147
int f = 0;
@@ -2509,7 +2509,7 @@ do_insecure_remove(RES* ssl, struct worker* worker, char* arg)
25092509
static void
25102510
do_insecure_list(RES* ssl, struct worker* worker)
25112511
{
2512-
char buf[257];
2512+
char buf[LDNS_MAX_DOMAINLEN];
25132513
struct trust_anchor* a;
25142514
if(worker->env.anchors) {
25152515
RBTREE_FOR(a, struct trust_anchor*, worker->env.anchors->tree) {
@@ -2606,7 +2606,7 @@ get_mesh_status(struct mesh_area* mesh, struct mesh_state* m,
26062606
}
26072607
} else if(s == module_wait_subquery) {
26082608
/* look in subs from mesh state to see what */
2609-
char nm[257];
2609+
char nm[LDNS_MAX_DOMAINLEN];
26102610
struct mesh_state_ref* sub;
26112611
snprintf(buf, len, "%s wants", modname);
26122612
l = strlen(buf);
@@ -2636,7 +2636,7 @@ do_dump_requestlist(RES* ssl, struct worker* worker)
26362636
struct mesh_area* mesh;
26372637
struct mesh_state* m;
26382638
int num = 0;
2639-
char buf[257];
2639+
char buf[LDNS_MAX_DOMAINLEN];
26402640
char timebuf[32];
26412641
char statbuf[10240];
26422642
if(!ssl_printf(ssl, "thread #%d\n", worker->thread_num))
@@ -2686,7 +2686,7 @@ dump_infra_host(struct lruhash_entry* e, void* arg)
26862686
struct infra_key* k = (struct infra_key*)e->key;
26872687
struct infra_data* d = (struct infra_data*)e->data;
26882688
char ip_str[1024];
2689-
char name[257];
2689+
char name[LDNS_MAX_DOMAINLEN];
26902690
int port;
26912691
if(a->ssl_failed)
26922692
return;
@@ -2953,7 +2953,7 @@ static void
29532953
do_list_auth_zones(RES* ssl, struct auth_zones* az)
29542954
{
29552955
struct auth_zone* z;
2956-
char buf[257], buf2[256];
2956+
char buf[LDNS_MAX_DOMAINLEN], buf2[256];
29572957
lock_rw_rdlock(&az->lock);
29582958
RBTREE_FOR(z, struct auth_zone*, &az->ztree) {
29592959
lock_rw_rdlock(&z->lock);
@@ -2983,7 +2983,7 @@ static void
29832983
do_list_local_zones(RES* ssl, struct local_zones* zones)
29842984
{
29852985
struct local_zone* z;
2986-
char buf[257];
2986+
char buf[LDNS_MAX_DOMAINLEN];
29872987
lock_rw_rdlock(&zones->lock);
29882988
RBTREE_FOR(z, struct local_zone*, &zones->ztree) {
29892989
lock_rw_rdlock(&z->lock);
@@ -3094,7 +3094,7 @@ rate_list(struct lruhash_entry* e, void* arg)
30943094
struct ratelimit_list_arg* a = (struct ratelimit_list_arg*)arg;
30953095
struct rate_key* k = (struct rate_key*)e->key;
30963096
struct rate_data* d = (struct rate_data*)e->data;
3097-
char buf[257];
3097+
char buf[LDNS_MAX_DOMAINLEN];
30983098
int lim = infra_find_ratelimit(a->infra, k->name, k->namelen);
30993099
int max = infra_rate_max(d, a->now, a->backoff);
31003100
if(a->all == 0) {

daemon/worker.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ answer_notify(struct worker* w, struct query_info* qinfo,
10821082

10831083
if(verbosity >= VERB_DETAIL) {
10841084
char buf[380];
1085-
char zname[255+1];
1085+
char zname[LDNS_MAX_DOMAINLEN];
10861086
char sr[25];
10871087
dname_str(qinfo->qname, zname);
10881088
sr[0]=0;
@@ -1413,7 +1413,7 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
14131413
return 0;
14141414
}
14151415
if(c->dnscrypt && !repinfo->is_dnscrypted) {
1416-
char buf[LDNS_MAX_DOMAINLEN+1];
1416+
char buf[LDNS_MAX_DOMAINLEN];
14171417
/* Check if this is unencrypted and asking for certs */
14181418
worker_check_request(c->buffer, worker, &check_result);
14191419
if(check_result.value != 0) {

iterator/iter_delegpt.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ delegpt_count_addr(struct delegpt* dp, size_t* numaddr, size_t* numres,
278278

279279
void delegpt_log(enum verbosity_value v, struct delegpt* dp)
280280
{
281-
char buf[LDNS_MAX_DOMAINLEN+1];
281+
char buf[LDNS_MAX_DOMAINLEN];
282282
struct delegpt_ns* ns;
283283
struct delegpt_addr* a;
284284
size_t missing=0, numns=0, numaddr=0, numres=0, numavail=0;

iterator/iter_fwd.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ forwards_insert_data(struct iter_forwards* fwd, uint16_t c, uint8_t* nm,
129129
node->namelabs = nmlabs;
130130
node->dp = dp;
131131
if(!rbtree_insert(fwd->tree, &node->node)) {
132-
char buf[257];
132+
char buf[LDNS_MAX_DOMAINLEN];
133133
dname_str(nm, buf);
134134
log_err("duplicate forward zone %s ignored.", buf);
135135
delegpt_free_mlc(dp);

iterator/iter_hints.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ hints_insert(struct iter_hints* hints, uint16_t c, struct delegpt* dp,
181181
node->noprime = (uint8_t)noprime;
182182
if(!name_tree_insert(&hints->tree, &node->node, dp->name, dp->namelen,
183183
dp->namelabs, c)) {
184-
char buf[257];
184+
char buf[LDNS_MAX_DOMAINLEN];
185185
dname_str(dp->name, buf);
186186
log_err("second hints for zone %s ignored.", buf);
187187
delegpt_free_mlc(dp);

iterator/iter_utils.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1492,8 +1492,8 @@ iter_stub_fwd_no_cache(struct module_qstate *qstate, struct query_info *qinf,
14921492
int stub_no_cache = stub->dp->no_cache;
14931493
lock_rw_unlock(&qstate->env->fwds->lock);
14941494
if(stub_no_cache) {
1495-
char qname[255+1];
1496-
char dpname[255+1];
1495+
char qname[LDNS_MAX_DOMAINLEN];
1496+
char dpname[LDNS_MAX_DOMAINLEN];
14971497
dname_str(qinf->qname, qname);
14981498
dname_str(stub->dp->name, dpname);
14991499
verbose(VERB_ALGO, "stub for %s %s has no_cache", qname, dpname);
@@ -1520,8 +1520,8 @@ iter_stub_fwd_no_cache(struct module_qstate *qstate, struct query_info *qinf,
15201520
int dp_no_cache = dp->no_cache;
15211521
lock_rw_unlock(&qstate->env->hints->lock);
15221522
if(dp_no_cache) {
1523-
char qname[255+1];
1524-
char dpname[255+1];
1523+
char qname[LDNS_MAX_DOMAINLEN];
1524+
char dpname[LDNS_MAX_DOMAINLEN];
15251525
dname_str(qinf->qname, qname);
15261526
dname_str(dp->name, dpname);
15271527
verbose(VERB_ALGO, "forward for %s %s has no_cache", qname, dpname);

iterator/iterator.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ auth_zone_delegpt(struct module_qstate* qstate, struct iter_qstate* iq,
10921092
/* cache is blacklisted and fallback, and we
10931093
* already have an auth_zone dp */
10941094
if(verbosity>=VERB_ALGO) {
1095-
char buf[255+1];
1095+
char buf[LDNS_MAX_DOMAINLEN];
10961096
dname_str(z->name, buf);
10971097
verbose(VERB_ALGO, "auth_zone %s "
10981098
"fallback because cache blacklisted",
@@ -1109,7 +1109,7 @@ auth_zone_delegpt(struct module_qstate* qstate, struct iter_qstate* iq,
11091109
* validation failure, and the zone allows
11101110
* fallback to the internet, query there. */
11111111
if(verbosity>=VERB_ALGO) {
1112-
char buf[255+1];
1112+
char buf[LDNS_MAX_DOMAINLEN];
11131113
dname_str(z->name, buf);
11141114
verbose(VERB_ALGO, "auth_zone %s "
11151115
"fallback because cache blacklisted",
@@ -2033,15 +2033,15 @@ query_for_targets(struct module_qstate* qstate, struct iter_qstate* iq,
20332033
return 1;
20342034
if(iq->depth > 0 && iq->target_count &&
20352035
iq->target_count[TARGET_COUNT_QUERIES] > MAX_TARGET_COUNT) {
2036-
char s[LDNS_MAX_DOMAINLEN+1];
2036+
char s[LDNS_MAX_DOMAINLEN];
20372037
dname_str(qstate->qinfo.qname, s);
20382038
verbose(VERB_QUERY, "request %s has exceeded the maximum "
20392039
"number of glue fetches %d", s,
20402040
iq->target_count[TARGET_COUNT_QUERIES]);
20412041
return 2;
20422042
}
20432043
if(iq->dp_target_count > MAX_DP_TARGET_COUNT) {
2044-
char s[LDNS_MAX_DOMAINLEN+1];
2044+
char s[LDNS_MAX_DOMAINLEN];
20452045
dname_str(qstate->qinfo.qname, s);
20462046
verbose(VERB_QUERY, "request %s has exceeded the maximum "
20472047
"number of glue fetches %d to a single delegation point",
@@ -2252,7 +2252,7 @@ processLastResort(struct module_qstate* qstate, struct iter_qstate* iq,
22522252
}
22532253
if(iq->depth > 0 && iq->target_count &&
22542254
iq->target_count[TARGET_COUNT_QUERIES] > MAX_TARGET_COUNT) {
2255-
char s[LDNS_MAX_DOMAINLEN+1];
2255+
char s[LDNS_MAX_DOMAINLEN];
22562256
dname_str(qstate->qinfo.qname, s);
22572257
verbose(VERB_QUERY, "request %s has exceeded the maximum "
22582258
"number of glue fetches %d", s,
@@ -3044,7 +3044,7 @@ processQueryTargets(struct module_qstate* qstate, struct iter_qstate* iq,
30443044
target_count_increase_global_quota(iq, 1);
30453045
if(iq->target_count && iq->target_count[TARGET_COUNT_GLOBAL_QUOTA]
30463046
> MAX_GLOBAL_QUOTA) {
3047-
char s[LDNS_MAX_DOMAINLEN+1];
3047+
char s[LDNS_MAX_DOMAINLEN];
30483048
dname_str(qstate->qinfo.qname, s);
30493049
verbose(VERB_QUERY, "request %s has exceeded the maximum "
30503050
"global quota on number of upstream queries %d", s,

libunbound/libworker.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ int libworker_bg(struct ub_ctx* ctx)
423423
static int
424424
fill_canon(struct ub_result* res, uint8_t* s)
425425
{
426-
char buf[255+2];
426+
char buf[LDNS_MAX_DOMAINLEN];
427427
dname_str(s, buf);
428428
res->canonname = strdup(buf);
429429
return res->canonname != 0;

pythonmod/interface.i

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ struct query_info {
204204

205205
%inline %{
206206
PyObject* dnameAsStr(PyObject* dname) {
207-
char buf[LDNS_MAX_DOMAINLEN+1];
207+
char buf[LDNS_MAX_DOMAINLEN];
208208
buf[0] = '\0';
209209
dname_str((uint8_t*)PyBytes_AsString(dname), buf);
210210
return PyString_FromString(buf);

respip/respip.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ respip_rewrite_reply(const struct query_info* qinfo,
961961
struct sockaddr_storage ss;
962962
socklen_t ss_len = 0;
963963
char nm[256], ip[256];
964-
char qn[255+1];
964+
char qn[LDNS_MAX_DOMAINLEN];
965965
if(!rdata2sockaddr(rep->rrsets[rrset_id]->entry.data, ntohs(rep->rrsets[rrset_id]->rk.type), rr_id, &ss, &ss_len))
966966
snprintf(ip, sizeof(ip), "invalidRRdata");
967967
else

0 commit comments

Comments
 (0)