From b61176f17b59a94750dff1f959231dadc4e6078a Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 21 Apr 2017 16:31:06 +0200 Subject: Update ldap/asn1/... files with current tinyldap --- scan_ldapsearchrequest.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'scan_ldapsearchrequest.c') diff --git a/scan_ldapsearchrequest.c b/scan_ldapsearchrequest.c index 94163db..3261b45 100644 --- a/scan_ldapsearchrequest.c +++ b/scan_ldapsearchrequest.c @@ -1,18 +1,21 @@ #include +#include #include "ldap.h" size_t scan_ldapsearchrequest(const char* src,const char* max, struct SearchRequest* s) { - size_t res,tmp,elen; + size_t res,tmp; unsigned long etmp; signed long ltmp; s->attributes=0; s->filter=0; if (!(res=scan_ldapstring(src,max,&s->baseObject))) goto error; if (!(tmp=scan_asn1ENUMERATED(src+res,max,&etmp))) goto error; - if (etmp>2) goto error; s->scope=etmp; res+=tmp; + if (etmp>2) goto error; + s->scope=etmp; res+=tmp; if (!(tmp=scan_asn1ENUMERATED(src+res,max,&etmp))) goto error; - if (etmp>3) goto error; s->derefAliases=etmp; res+=tmp; + if (etmp>3) goto error; + s->derefAliases=etmp; res+=tmp; if (!(tmp=scan_asn1INTEGER(src+res,max,<mp)) || ltmp<0) goto error; s->sizeLimit=(unsigned long)ltmp; res+=tmp; @@ -24,20 +27,19 @@ size_t scan_ldapsearchrequest(const char* src,const char* max, if (!(tmp=scan_ldapsearchfilter(src+res,max,&s->filter))) goto error; res+=tmp; /* now for the attributelist */ - if (!(tmp=scan_asn1SEQUENCE(src+res,max,&elen))) goto error; + if (!(tmp=scan_asn1SEQUENCE(src+res,max,&etmp))) goto error; res+=tmp; { - const char* nmax=src+res+elen; + const char* nmax=src+res+etmp; //#define nmax max struct AttributeDescriptionList** a=&s->attributes; if (nmax>max) goto error; for (;;) { if (src+res>nmax) goto error; if (src+res==nmax) break; - if (!*a) *a=malloc(sizeof(struct AttributeDescriptionList)); + if (!*a) *a=calloc(1,sizeof(struct AttributeDescriptionList)); if (!*a) goto error; - (*a)->next=0; - if (!(tmp=scan_ldapstring(src+res,nmax,&(*a)->a))) goto error; + if (!(tmp=scan_ldapstring(src+res,nmax,&(*a)->a))) { free(*a); *a=0; goto error; } res+=tmp; a=&(*a)->next; } @@ -50,6 +52,7 @@ error: void free_ldapsearchrequest(struct SearchRequest* s) { if (s->attributes) - free_ldapadl(s->attributes); // ->next !? + free_ldapadl(s->attributes); free_ldapsearchfilter(s->filter); + memset(s,0,sizeof(*s)); } -- cgit v1.2.3-55-g7522