summaryrefslogtreecommitdiffstats
path: root/scan_ldapsearchrequest.c
diff options
context:
space:
mode:
authorSimon Rettberg2017-04-21 16:31:06 +0200
committerSimon Rettberg2017-04-21 16:31:06 +0200
commitb61176f17b59a94750dff1f959231dadc4e6078a (patch)
tree88ee419323ba332a1dd06c5aa801c87f59b36bb3 /scan_ldapsearchrequest.c
parentldadp.h: Add missing SearchRequestReference opcode (diff)
downloadldadp-b61176f17b59a94750dff1f959231dadc4e6078a.tar.gz
ldadp-b61176f17b59a94750dff1f959231dadc4e6078a.tar.xz
ldadp-b61176f17b59a94750dff1f959231dadc4e6078a.zip
Update ldap/asn1/... files with current tinyldap
Diffstat (limited to 'scan_ldapsearchrequest.c')
-rw-r--r--scan_ldapsearchrequest.c21
1 files changed, 12 insertions, 9 deletions
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 <stdlib.h>
+#include <string.h>
#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,&ltmp)) || 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));
}