1 diff --git a/lib/master_tok.l b/lib/master_tok.l
2 index 48bc233..5450753 100644
5 @@ -108,8 +108,8 @@ AT_DC ([dD][[cC])
8 DNATTRSTR {AT_CN}|{AT_NMN}|{AT_AMN}|{AT_OU}|{AT_DC}|{AT_O}|{AT_C}
9 -DNNAMESTR ([[:alnum:]_.\-]+)
10 -DNNAMETRM (,|{WS}{NL}|{WS}#.*|\x00)
11 +DNNAMESTR ([[:alnum:]_.\- ]+)
12 +DNNAMETRM (,|{OPTWS}{NL}|{OPTWS}#.*|{OPTWS}\x00)
15 MULTI ((multi)(,(sun|hesiod))?(:{OPTWS}|{WS}))
16 @@ -379,7 +379,13 @@ void master_set_scan_buffer(const char *buffer)
20 - line_lim = line + strlen(buffer);
22 + * Ensure buffer is 1 greater than string and is zeroed before
23 + * the parse so we can fit the extra NULL which allows us to
24 + * explicitly match an end of line within the buffer (ie. the
25 + * need for 2 NULLS when parsing in memeory buffers).
27 + line_lim = line + strlen(buffer) + 1;
30 #define min(a,b) (((a) < (b)) ? (a) : (b))
31 diff --git a/modules/lookup_file.c b/modules/lookup_file.c
32 index 921b32b..c093415 100644
33 --- a/modules/lookup_file.c
34 +++ b/modules/lookup_file.c
35 @@ -479,7 +479,7 @@ int lookup_read_master(struct master *master, time_t age, void *context)
37 master->name = save_name;
39 - blen = path_len + 1 + ent_len + 1;
40 + blen = path_len + 1 + ent_len + 2;
41 buffer = malloc(blen);
44 diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
45 index 00215af..dfb3054 100644
46 --- a/modules/lookup_ldap.c
47 +++ b/modules/lookup_ldap.c
48 @@ -1368,7 +1368,7 @@ int lookup_read_master(struct master *master, time_t age, void *context)
52 - blen = strlen(*keyValue) + 1 + strlen(*values) + 1;
53 + blen = strlen(*keyValue) + 1 + strlen(*values) + 2;
54 if (blen > PARSE_MAX_BUF) {
55 error(logopt, MODPREFIX "map entry too long");
56 ldap_value_free(values);
57 diff --git a/modules/lookup_nisplus.c b/modules/lookup_nisplus.c
58 index ff8bd49..bcdaeeb 100644
59 --- a/modules/lookup_nisplus.c
60 +++ b/modules/lookup_nisplus.c
61 @@ -90,7 +90,7 @@ int lookup_read_master(struct master *master, time_t age, void *context)
64 char buf[MAX_ERR_BUF];
68 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
69 tablename = alloca(strlen(ctxt->mapname) + strlen(ctxt->domainname) + 20);
70 @@ -138,11 +138,13 @@ int lookup_read_master(struct master *master, time_t age, void *context)
72 ent = ENTRY_VAL(this, 1);
74 - buffer = malloc(ENTRY_LEN(this, 0) + 1 + ENTRY_LEN(this, 1) + 1);
75 + len = ENTRY_LEN(this, 0) + 1 + ENTRY_LEN(this, 1) + 2;
76 + buffer = malloc(len);
78 logerr(MODPREFIX "could not malloc parse buffer");
81 + memset(buffer, 0, len);
85 diff --git a/modules/lookup_yp.c b/modules/lookup_yp.c
86 index 63fc8e3..7ba6940 100644
87 --- a/modules/lookup_yp.c
88 +++ b/modules/lookup_yp.c
89 @@ -178,7 +178,7 @@ int yp_all_master_callback(int status, char *ypkey, int ypkeylen,
90 *(ypkey + ypkeylen) = '\0';
91 *(val + vallen) = '\0';
93 - len = ypkeylen + 1 + vallen + 1;
94 + len = ypkeylen + 1 + vallen + 2;