Skip to content

Commit ed951b8

Browse files
committed
fixed compilation with modern systems, warnings removed, minor TCP bug fixed with practially no real world effects.
1 parent 071893d commit ed951b8

17 files changed

+170
-111
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.depend
2+
*.o
3+
yaku-ns
4+
getzone

assert.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#define assert(x) \
2222
do { \
2323
if ((x) == 0) { \
24-
log(VERB_FORCE, \
24+
ylog(VERB_FORCE, \
2525
"assert failed: %s is false in %s at line %d\n", \
2626
#x, __FILE__, __LINE__); \
2727
abort(); \

axfr_out.c

+12-12
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
#include <string.h>
7676
#include <stdlib.h>
7777
#include <signal.h>
78-
#include <wait.h>
7978

8079
#define AXFR_CLIENT_MAX 50
8180
#define AXFR_CLIENT_TIMEOUT 120 /* At least 2 min, see RFC1034 */
@@ -132,7 +131,7 @@ int axfr_init(void)
132131
} else {
133132
struct in_addr tmp;
134133
if (inet_aton(bindaddr, &tmp) == 0) {
135-
log(VERB_FORCE, "[axfr_init] bad IP address "
134+
ylog(VERB_FORCE, "[axfr_init] bad IP address "
136135
"for binding\n");
137136
exit(1);
138137
}
@@ -184,10 +183,11 @@ void tcp_handler(void)
184183
{
185184
HEADER *hdr;
186185
byte tmp[2];
187-
byte request[512]; /* even under TCP we limit to 512 bytes */
186+
char request[512]; /* even under TCP we limit to 512 bytes */
188187
byte *data; /* points after the DNS header */
189188
int data_size; /* data size left */
190-
int new, addrlen; /* the new socket fd and the accept addrlen */
189+
socklen_t addrlen;
190+
int new; /* new socket fd */
191191
int query_count; /* question sections in the query */
192192
unsigned int size; /* query size */
193193
int retval, n_read;
@@ -213,14 +213,14 @@ void tcp_handler(void)
213213

214214
/* Check the ACL */
215215
if (acl_check_axfr(straddr) == ACL_DENY) {
216-
log(VERB_MED, "AXFR: access denied to client %s-%d\n",
216+
ylog(VERB_MED, "AXFR: access denied to client %s-%d\n",
217217
straddr, ntohs(newsa.sin_port));
218218
goto out;
219219
}
220220

221221
/* Max number of clients reached? */
222222
if (axfr_clients >= AXFR_CLIENT_MAX) {
223-
log(VERB_MED, "AXFR: too many AXFR clients, "
223+
ylog(VERB_MED, "AXFR: too many AXFR clients, "
224224
"access denied to %s-%d\n",
225225
straddr, ntohs(newsa.sin_port));
226226
goto out;
@@ -268,14 +268,14 @@ void tcp_handler(void)
268268
hdr->opcode != 0)
269269
goto child_out;
270270
data_size = size;
271-
data = request + sizeof(HEADER);
271+
data = (unsigned char*)request + sizeof(HEADER);
272272
query_count = ntohs(hdr->qdcount);
273273
if (query_count != 1)
274274
goto child_out;
275275

276276
/* parse the query */
277-
retval = name_decode(data, data_size, request,
278-
&name, 1);
277+
retval = name_decode(data, data_size,
278+
(unsigned char*)request, &name, 1);
279279
if (name == NULL)
280280
goto child_out;
281281
updatep(retval);
@@ -288,19 +288,19 @@ void tcp_handler(void)
288288
/* The only two accepted requests under TCP are
289289
* IN/AXFR and IN/SOA */
290290
if (qclass == C_IN && qtype == T_AXFR) {
291-
log(VERB_LOW, "AXFR requested for (%s) from "
291+
ylog(VERB_LOW, "AXFR requested for (%s) from "
292292
"%s-%d\n", name, straddr,
293293
ntohs(newsa.sin_port));
294294
send_zone(hdr, request+sizeof(HEADER), retval+4,
295295
name, new);
296296
} else if (qclass == C_IN && qtype == T_SOA) {
297-
log(VERB_MED, "TCP IN SOA requested for (%s) from "
297+
ylog(VERB_MED, "TCP IN SOA requested for (%s) from "
298298
"%s-%d\n", name, straddr,
299299
ntohs(newsa.sin_port));
300300
send_soa(hdr, request+sizeof(HEADER), retval+4,
301301
name, new);
302302
} else {
303-
log(VERB_MED, "TCP unaccepted request (%s %s) "
303+
ylog(VERB_MED, "TCP unaccepted request (%s %s) "
304304
"from %s-%d\n",
305305
qclass_to_str(qclass),
306306
qtype_to_str(qtype),

cache.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ int cache_free_expired(void)
187187
}
188188
current = ht_value(&cache_table, index);
189189
if (current->creat_timestamp + current->ttl <= (unsigned)now) {
190-
log(VERB_HIG, "Expired cache entry %s %s %s\n",
190+
ylog(VERB_HIG, "Expired cache entry %s %s %s\n",
191191
qtype_to_str(current->qtype),
192192
qclass_to_str(current->qclass),
193193
current->name);
@@ -217,7 +217,7 @@ struct cacheentry *cache_search_entry(char *name, int qclass, int qtype)
217217
/* Expired? Free the entry and return NULL */
218218
if (opt_cachenoexpire == 0 &&
219219
cache->creat_timestamp + cache->ttl <= (unsigned)now) {
220-
log(VERB_HIG, "Expired cache entry %s %s %s\n",
220+
ylog(VERB_HIG, "Expired cache entry %s %s %s\n",
221221
qtype_to_str(cache->qtype),
222222
qclass_to_str(cache->qclass),
223223
cache->name);

config.c

+21-21
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ int config_read(char *filename)
145145
} else {
146146
fp = fopen(filename, "r");
147147
if (fp == NULL) {
148-
log(VERB_FORCE, "Can't open the config file %s\n",
148+
ylog(VERB_FORCE, "Can't open the config file %s\n",
149149
filename);
150150
perror("fopen");
151-
log(VERB_FORCE, "Remember that you MUST "
151+
ylog(VERB_FORCE, "Remember that you MUST "
152152
"specify the absolute path\n");
153153
exit(1);
154154
}
@@ -170,8 +170,8 @@ int config_read(char *filename)
170170

171171
static void config_error(int linenum, char *line, char *errormsg)
172172
{
173-
log(VERB_FORCE, "--\n`%s' at line %d\n", errormsg, linenum);
174-
log(VERB_FORCE, "%d: %s--\n", linenum, line);
173+
ylog(VERB_FORCE, "--\n`%s' at line %d\n", errormsg, linenum);
174+
ylog(VERB_FORCE, "%d: %s--\n", linenum, line);
175175
exit(1);
176176
}
177177

@@ -190,9 +190,9 @@ static int op_include(int argc, char **argv)
190190

191191
if (securelevel >= 1)
192192
return CERROR_PERM;
193-
log(VERB_HIG, "> include %s\n", argv[1]);
193+
ylog(VERB_HIG, "> include %s\n", argv[1]);
194194
config_read(argv[1]);
195-
log(VERB_HIG, "< end of inclusion of %s\n", argv[1]);
195+
ylog(VERB_HIG, "< end of inclusion of %s\n", argv[1]);
196196
return CERROR_SUCCESS;
197197
}
198198

@@ -206,7 +206,7 @@ static int op_forwarder(int argc, char **argv)
206206
&forward_server[forward_server_count]) == 0)
207207
return CERROR_BADIP;
208208
opt_forward = 1;
209-
log(VERB_HIG, "(forwarding) external server: %s\n", argv[1]);
209+
ylog(VERB_HIG, "(forwarding) external server: %s\n", argv[1]);
210210
forward_server_count++;
211211
/* accept responses from this external server */
212212
acl_add_rule(argv[1], &acl_dns_allow_head, &acl_dns_allow_tail);
@@ -221,9 +221,9 @@ static int op_forward_max(int argc, char **argv)
221221
if (forward_max <= 0) {
222222
forward_max = 0;
223223
opt_forward = 0;
224-
log(VERB_MED, "forwarding disabled\n");
224+
ylog(VERB_MED, "forwarding disabled\n");
225225
} else {
226-
log(VERB_HIG, "forwarding: max queue %d\n", forward_max);
226+
ylog(VERB_HIG, "forwarding: max queue %d\n", forward_max);
227227
}
228228
return CERROR_SUCCESS;
229229
}
@@ -236,7 +236,7 @@ static int op_forward_entry_timeout(int argc, char **argv)
236236
if (forward_timeout <= 0) {
237237
return CERROR_INVALID;
238238
} else {
239-
log(VERB_HIG, "forwarding: entry timeout %d\n", forward_timeout);
239+
ylog(VERB_HIG, "forwarding: entry timeout %d\n", forward_timeout);
240240
}
241241
return CERROR_SUCCESS;
242242
}
@@ -249,7 +249,7 @@ static int op_forward_next_timeout(int argc, char **argv)
249249
if (next_server_timeout < 0) {
250250
return CERROR_INVALID;
251251
} else {
252-
log(VERB_HIG, "forwarding: next server timeout %d\n",
252+
ylog(VERB_HIG, "forwarding: next server timeout %d\n",
253253
next_server_timeout);
254254
}
255255
return CERROR_SUCCESS;
@@ -263,9 +263,9 @@ static int op_cache_max(int argc, char **argv)
263263
if (cache_max <= 0) {
264264
cache_max = 0;
265265
opt_cache = 0;
266-
log(VERB_MED, "cache: disabled\n");
266+
ylog(VERB_MED, "cache: disabled\n");
267267
} else {
268-
log(VERB_HIG, "cache: max size %d\n", cache_max);
268+
ylog(VERB_HIG, "cache: max size %d\n", cache_max);
269269
}
270270
return CERROR_SUCCESS;
271271
}
@@ -275,7 +275,7 @@ static int op_cache_minttl(int argc, char **argv)
275275
ARG_UNUSED(argc)
276276

277277
cache_minttl = atoi(argv[1]);
278-
log(VERB_HIG, "cache: min TTL %d\n", cache_minttl);
278+
ylog(VERB_HIG, "cache: min TTL %d\n", cache_minttl);
279279
return CERROR_SUCCESS;
280280
}
281281

@@ -284,7 +284,7 @@ static int op_cache_maxttl(int argc, char **argv)
284284
ARG_UNUSED(argc)
285285

286286
cache_maxttl = atoi(argv[1]);
287-
log(VERB_HIG, "cache: max TTL %d\n", cache_maxttl);
287+
ylog(VERB_HIG, "cache: max TTL %d\n", cache_maxttl);
288288
return CERROR_SUCCESS;
289289
}
290290

@@ -326,7 +326,7 @@ static int op_ttl(int argc, char **argv)
326326
ARG_UNUSED(argc)
327327

328328
local_ttl = atoi(argv[1]);
329-
log(VERB_HIG, "> Time To Live is %u\n", local_ttl);
329+
ylog(VERB_HIG, "> Time To Live is %u\n", local_ttl);
330330
return CERROR_SUCCESS;
331331
}
332332

@@ -335,7 +335,7 @@ static int op_tcp_requests_for_connection(int argc, char **argv)
335335
ARG_UNUSED(argc)
336336

337337
opt_tcp_requests_for_connection = atoi(argv[1]);
338-
log(VERB_HIG, "TCP requests for connection set to %d\n",
338+
ylog(VERB_HIG, "TCP requests for connection set to %d\n",
339339
opt_tcp_requests_for_connection);
340340
return CERROR_SUCCESS;
341341
}
@@ -346,13 +346,13 @@ static int op_class(int argc, char **argv)
346346

347347
if (!strcasecmp(argv[1], "IN")) {
348348
local_class = C_IN;
349-
log(VERB_HIG, "> Class is IN\n");
349+
ylog(VERB_HIG, "> Class is IN\n");
350350
} else if (!strcasecmp(argv[1], "CHAOS")) {
351351
local_class = C_CHAOS;
352-
log(VERB_HIG, "> Class is CHAOS\n");
352+
ylog(VERB_HIG, "> Class is CHAOS\n");
353353
} else if (!strcasecmp(argv[1], "ANY")) {
354354
local_class = C_ANY;
355-
log(VERB_HIG, "> Class is ANY\n");
355+
ylog(VERB_HIG, "> Class is ANY\n");
356356
} else {
357357
return CERROR_INVALID;
358358
}
@@ -396,7 +396,7 @@ static int op_acl(int argc, char **argv)
396396
return CERROR_BADACL;
397397
}
398398
acl_add_rule(argv[j], head, tail);
399-
log(VERB_HIG, "acl: loaded %s %s\n", argv[1], argv[j]);
399+
ylog(VERB_HIG, "acl: loaded %s %s\n", argv[1], argv[j]);
400400
}
401401
return CERROR_SUCCESS;
402402
}

0 commit comments

Comments
 (0)