From 340ce0543cfa786fef657b2562107e529dedd6ea Mon Sep 17 00:00:00 2001 From: leitner Date: Sun, 8 Apr 2018 18:56:18 +0000 Subject: [PATCH] be stricter about records with no / two dn --- ldif_parse.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ldif_parse.c b/ldif_parse.c index d59daea..7e3fdd5 100644 --- a/ldif_parse.c +++ b/ldif_parse.c @@ -20,6 +20,8 @@ mstorage_t stringtable; uint32_t dn, objectClass; unsigned long lines; +unsigned long recstart; + /* this is called after each record. * If it returns -1, ldif_parse will exit immediately. * If it returns 0, ldif_parse will continue parsing and overwrite the @@ -234,8 +236,22 @@ lookagain: // write(2,"h",1); goto nomem; } + if (tmp==(uint32_t)dn && (*l)->dn!=(uint32_t)-1) { + buffer_putm(buffer_2,"\r\n\n",filename,":"); + buffer_putulong(buffer_2,recstart+1); + buffer_putsflush(buffer_2,": error: record has two dn entries\n"); + exit(1); + } addattribute(l,tmp,val); + if ((*l)->dn==(uint32_t)-1) { + buffer_putm(buffer_2,"\r\n\n",filename,":"); + buffer_putulong(buffer_2,recstart+1); + buffer_putsflush(buffer_2,": error: record without dn\n"); + exit(1); + } + recstart=lines; + m=0; if (ldif_parse_callback) { switch (ldif_parse_callback(*l)) { @@ -314,6 +330,12 @@ lookagain: // write(2,"l",1); goto nomem; } + if (tmp==(uint32_t)dn && (*l)->dn!=(uint32_t)-1) { + buffer_putm(buffer_2,"\r\n\n",filename,":"); + buffer_putulong(buffer_2,recstart+1); + buffer_putsflush(buffer_2,": error: record has two dn entries\n"); + exit(1); + } addattribute(l,tmp,val); #endif } while (!eof);