Commit Diff
Diff:
8d753d401a4362faedc11124a91baffeae1a7d19
0d1b8743cd6c4f6a0f4e15fc196c2036c6a1f466
Commit:
0d1b8743cd6c4f6a0f4e15fc196c2036c6a1f466
Tree:
af203182782c8893f9d362ac07c2510ea7be284c
Author:
pbug <pbug@delphinusdns.org>
Committer:
pbug <pbug@delphinusdns.org>
Date:
Fri Jan 27 21:24:14 2012 UTC
Message:
* in dns.h add a TSIG type, something on what's to come perhaps * in parse.c fix a nasty bug that popped up on OpenBSD/macppc basically the ns and rp entries in the SOA were 0 due to an integer overflow in the parsing, this caused erroneous ANY packets and AXFR's which use the same code. compiles and tested on OpenBSD/macppc and OpenBSD/i386
blob - 1af4c8cdb95961bdefd198eb5841be98c3647dc2
blob + c7a27d36f218f950165850f65f22e7ae200ddd54
--- dns.h
+++ dns.h
@@ -135,6 +135,7 @@ struct dns_question_hdr {
#define DNS_TYPE_MX 15
#define DNS_TYPE_TXT 16
+#define DNS_TYPE_TSIG 250 /* RFC 2845, page 3 */
#define DNS_TYPE_IXFR 251 /* RFC 1995, page 2 */
#define DNS_TYPE_AXFR 252 /* RFC 5936, page 10 */
#define DNS_TYPE_ANY 255
blob - 39ba8e75333aa4e584698c347e280283e70be75d
blob + d372c794c40177892648f189354ef3f1704a11e7
--- parse.c
+++ parse.c
@@ -97,7 +97,7 @@ static u_int32_t config = 0;
struct logging logging;
int axfrport = 0;
-static const char rcsid[] = "$Id: parse.c,v 1.32 2011/09/19 19:59:23 pbug Exp $";
+static const char rcsid[] = "$Id: parse.c,v 1.33 2012/01/27 21:24:14 pbug Exp $";
/*
* PARSE_FILE - parse the configfile XXX rewrite me in yacc :(
@@ -179,6 +179,7 @@ parse_file(DB *db, char *file)
static int
parse_file0(char *filename, DB *db, FILE *f)
{
+ int convert;
int len, i, error;
int tokenlen;
u_int16_t type;
@@ -196,6 +197,7 @@ parse_file0(char *filename, DB *db, FILE *f)
char *converted_name;
char *p, *endline, *start, *starttoken;
char *address;
+ char *name;
char save;
DBT key, data;
@@ -706,17 +708,19 @@ parse_file0(char *filename, DB *db, FILE *f)
save = *p;
*p = 0;
- {
- char *name;
+ if ((name = dns_label(starttoken, (int *)&convert)) == NULL) {
+ fprintf(stderr, "illegal nameserver, skipping line %d\n", line);
+ goto skip;
+ }
- if ((name = dns_label(starttoken, (int *)&sdomain.soa.nsserver_len)) == NULL) {
- fprintf(stderr, "illegal nameserver, skipping line %d\n", line);
- goto skip;
- }
-
- memcpy((char *)&sdomain.soa.nsserver[0], name, sdomain.soa.nsserver_len);
- free (name);
+ if (convert > 0xff || convert < 0) {
+ fprintf(stderr, "illegal convert value");
+ return -1;
}
+
+ sdomain.soa.nsserver_len = convert;
+ memcpy((char *)&sdomain.soa.nsserver[0], name, sdomain.soa.nsserver_len);
+ free (name);
*p = save;
@@ -737,17 +741,19 @@ parse_file0(char *filename, DB *db, FILE *f)
save = *p;
*p = 0;
- {
- char *name;
+ if ((name = dns_label(starttoken, (int *)&convert)) == NULL) {
+ fprintf(stderr, "illegal nameserver, skipping line %d\n", line);
+ goto skip;
+ }
- if ((name = dns_label(starttoken, (int *)&sdomain.soa.rp_len)) == NULL) {
- fprintf(stderr, "illegal nameserver, skipping line %d\n", line);
- goto skip;
- }
-
- memcpy((char *)&sdomain.soa.responsible_person[0], name, sdomain.soa.rp_len);
- free (name);
+ if (convert > 0xff || convert < 0) {
+ fprintf(stderr, "illegal convert value");
+ return -1;
}
+
+ sdomain.soa.rp_len = convert;
+ memcpy((char *)&sdomain.soa.responsible_person[0], name, sdomain.soa.rp_len);
+ free (name);
*p = save;
repomaster@centroid.eu