diff --git a/ldap_match_mapped.c b/ldap_match_mapped.c index c3a3c53..a30b379 100644 --- a/ldap_match_mapped.c +++ b/ldap_match_mapped.c @@ -28,12 +28,13 @@ static int substringmatch(struct Substring* x,const char* attr,int ignorecase) { found: break; case any: - if (x->s.ls.l-strlen(attr); ++i) - if (!diff(x->s.s+i,x->s.l,attr)) goto found; + if (x->s.l>strlen(attr)) return 0; + for (i=0; is.l-strlen(attr); ++i) { + if (!diff(x->s.s,x->s.l,attr+i)) goto found; + } return 0; case suffix: - if (diff(x->s.s+x->s.l-strlen(attr),x->s.l,attr)) return 0; + if (diff(x->s.s,x->s.l,attr+strlen(attr)-x->s.l)) return 0; } x=x->next; } diff --git a/tinyldap.c b/tinyldap.c index 6f605ae..c30e15b 100644 --- a/tinyldap.c +++ b/tinyldap.c @@ -464,6 +464,7 @@ static void answerwith(uint32 ofs,struct SearchRequest* sr,long messageid,int ou for (; ia,map+uint32_read(map+ofs+i*8))) { val=map+uint32_read(map+ofs+i*8+4); + ++i; break; } } @@ -477,19 +478,19 @@ nomem: (*pal)->type=adl->a; { struct AttributeDescriptionList** a=&(*pal)->values; - while (ia.s=val; - (*a)->a.l=strlen(val); - (*a)->next=0; - for (;ia,map+uint32_read(map+ofs+i*8))) { - val=map+uint32_read(map+ofs+i*8+4); - ++i; - break; - } - } +add_attribute: + *a=malloc(sizeof(struct AttributeDescriptionList)); + if (!*a) goto nomem; + (*a)->a.s=val; + (*a)->a.l=strlen(val); + for (;ia,map+uint32_read(map+ofs+i*8))) { + val=map+uint32_read(map+ofs+i*8+4); + ++i; + a=&(*a)->next; + goto add_attribute; + } + (*a)->next=0; } (*pal)->next=0; pal=&(*pal)->next;