summaryrefslogtreecommitdiff
path: root/rr.c
diff options
context:
space:
mode:
authorMatthijs Mekking <matje@NLnetLabs.nl>2010-09-02 15:55:27 +0200
committerMatthijs Mekking <matje@NLnetLabs.nl>2010-09-02 15:55:27 +0200
commit5c80ba36afa5f1bbd3cae19ea50b7a9a4f376931 (patch)
treee883108a71885936817e25b4b2d49b11403123c4 /rr.c
parentd969e3015bc3431947a12baa220b4fbf7a2c211b (diff)
downloadldns-5c80ba36afa5f1bbd3cae19ea50b7a9a4f376931.tar.gz
bug 236
Diffstat (limited to 'rr.c')
-rw-r--r--rr.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/rr.c b/rr.c
index 307a4309..9a3aa1d9 100644
--- a/rr.c
+++ b/rr.c
@@ -586,11 +586,11 @@ ldns_rr_new_frm_fp_l(ldns_rr **newrr, FILE *fp, uint32_t *default_ttl, ldns_rdf
char *line;
const char *endptr; /* unused */
ldns_rr *rr;
- char *keyword;
uint32_t ttl;
ldns_rdf *tmp;
ldns_status s;
ssize_t size;
+ int offset = 0;
if (default_ttl) {
ttl = *default_ttl;
@@ -621,12 +621,16 @@ ldns_rr_new_frm_fp_l(ldns_rr **newrr, FILE *fp, uint32_t *default_ttl, ldns_rdf
return LDNS_STATUS_SYNTAX_EMPTY;
}
- if ((keyword = strstr(line, "$ORIGIN "))) {
+ if (strncmp(line, "$ORIGIN", 7) == 0 && isspace(line[7])) {
if (*origin) {
ldns_rdf_deep_free(*origin);
*origin = NULL;
}
- tmp = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_DNAME, keyword + 8);
+ offset = 8;
+ while (isspace(line[offset])) {
+ offset++;
+ }
+ tmp = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_DNAME, line + offset);
if (!tmp) {
/* could not parse what next to $ORIGIN */
LDNS_FREE(line);
@@ -634,12 +638,16 @@ ldns_rr_new_frm_fp_l(ldns_rr **newrr, FILE *fp, uint32_t *default_ttl, ldns_rdf
}
*origin = tmp;
s = LDNS_STATUS_SYNTAX_ORIGIN;
- } else if ((keyword = strstr(line, "$TTL "))) {
+ } else if (strncmp(line, "$TTL", 4) == 0 && isspace(line[4])) {
+ offset = 5;
+ while (isspace(line[offset])) {
+ offset++;
+ }
if (default_ttl) {
- *default_ttl = ldns_str2period(keyword + 5, &endptr);
+ *default_ttl = ldns_str2period(line + offset, &endptr);
}
s = LDNS_STATUS_SYNTAX_TTL;
- } else if (strstr(line, "$INCLUDE ")) {
+ } else if (strncmp(line, "$INCLUDE", 8) == 0) {
s = LDNS_STATUS_SYNTAX_INCLUDE;
} else {
if (origin && *origin) {