remove lots of gcc 4 warnings

This commit is contained in:
leitner
2005-10-14 14:35:16 +00:00
parent 043b02ede6
commit 7966fa0c86
25 changed files with 152 additions and 95 deletions

View File

@@ -82,7 +82,7 @@ acl: acl.c ldap.a asn1.a
.PHONY: clean tar
clean:
rm -f t t[1-9] *.[ao] bindrequest tinyldap ldapclient data \
rm -f t t[1-9] *.[ao] bindrequest tinyldap ldapclient \
parse tinyldap_standalone tinyldap_debug ldapclient_str addindex \
dumpidx idx2ldif md5password *.da *.bbg *.bb *.gcov gmon.out *.gcda \
*.gcno
@@ -90,34 +90,6 @@ dumpidx idx2ldif md5password *.da *.bbg *.bb *.gcov gmon.out *.gcda \
tar: clean
cd ..; tar cvvf tinyldap.tar.bz2 tinyldap --use=bzip2 --exclude capture --exclude CVS --exclude exp.ldif --exclude polyp* --exclude rfc*
fmt_asn1int.o: fmt_asn1int.c
fmt_asn1intpayload.o: fmt_asn1intpayload.c
fmt_asn1length.o: fmt_asn1length.c asn1.h
fmt_asn1string.o: fmt_asn1string.c asn1.h
fmt_asn1tag.o: fmt_asn1tag.c asn1.h
fmt_asn1transparent.o: fmt_asn1transparent.c asn1.h
fmt_ldapbindrequest.o: fmt_ldapbindrequest.c asn1.h ldap.h
fmt_ldapbindresponse.o: fmt_ldapbindresponse.c asn1.h ldap.h
fmt_ldapmessage.o: fmt_ldapmessage.c asn1.h ldap.h
scan_asn1BOOLEAN.o: scan_asn1BOOLEAN.c asn1.h
scan_asn1ENUMERATED.o: scan_asn1ENUMERATED.c asn1.h
scan_asn1INTEGER.o: scan_asn1INTEGER.c asn1.h
scan_asn1SEQUENCE.o: scan_asn1SEQUENCE.c asn1.h
scan_asn1STRING.o: scan_asn1STRING.c asn1.h
scan_asn1int.o: scan_asn1int.c asn1.h
scan_asn1length.o: scan_asn1length.c asn1.h
scan_asn1string.o: scan_asn1string.c asn1.h
scan_asn1tag.o: scan_asn1tag.c asn1.h
scan_ldapava.o: scan_ldapava.c asn1.h ldap.h
scan_ldapbindrequest.o: scan_ldapbindrequest.c asn1.h ldap.h
scan_ldapbindresponse.o: scan_ldapbindresponse.c asn1.h ldap.h
scan_ldapmessage.o: scan_ldapmessage.c asn1.h ldap.h
scan_ldapsearchfilter.o: scan_ldapsearchfilter.c asn1.h ldap.h
scan_ldapsearchrequest.o: scan_ldapsearchrequest.c asn1.h ldap.h
scan_ldapstring.o: scan_ldapstring.c asn1.h ldap.h
scan_ldapresult.o: scan_ldapresult.c asn1.h ldap.h
ldif_parse.o: ldif_parse.c strduptab.h strstorage.h ldif.h
tinyldap.o: tinyldap.c ldap.h ldif.h
@@ -129,3 +101,48 @@ strduptab.o: strduptab.c strduptab.h strstorage.h
strstorage.o: strstorage.c strstorage.h
freeava.o: freeava.c ldap.h
freefilter.o: freefilter.c ldap.h
fmt_asn1int.o: fmt_asn1int.c asn1.h
fmt_asn1intpayload.o: fmt_asn1intpayload.c asn1.h
fmt_asn1length.o: fmt_asn1length.c asn1.h
fmt_asn1sint.o: fmt_asn1sint.c asn1.h
fmt_asn1sintpayload.o: fmt_asn1sintpayload.c asn1.h
fmt_asn1string.o: fmt_asn1string.c asn1.h
fmt_asn1tag.o: fmt_asn1tag.c asn1.h
fmt_asn1transparent.o: fmt_asn1transparent.c asn1.h
fmt_ldapadl.o: fmt_ldapadl.c asn1.h ldap.h
fmt_ldapava.o: fmt_ldapava.c asn1.h ldap.h
fmt_ldapbindrequest.o: fmt_ldapbindrequest.c asn1.h ldap.h
fmt_ldapmessage.o: fmt_ldapmessage.c asn1.h ldap.h
fmt_ldappal.o: fmt_ldappal.c asn1.h ldap.h
fmt_ldapresult.o: fmt_ldapresult.c asn1.h ldap.h
fmt_ldapsearchfilter.o: fmt_ldapsearchfilter.c asn1.h ldap.h
fmt_ldapsearchfilterstring.o: fmt_ldapsearchfilterstring.c ldap.h
fmt_ldapsearchrequest.o: fmt_ldapsearchrequest.c asn1.h ldap.h
fmt_ldapsearchresultentry.o: fmt_ldapsearchresultentry.c asn1.h ldap.h
fmt_ldapstring.o: fmt_ldapstring.c asn1.h ldap.h
scan_asn1BOOLEAN.o: scan_asn1BOOLEAN.c asn1.h
scan_asn1ENUMERATED.o: scan_asn1ENUMERATED.c asn1.h
scan_asn1INTEGER.o: scan_asn1INTEGER.c asn1.h
scan_asn1SEQUENCE.o: scan_asn1SEQUENCE.c asn1.h
scan_asn1SET.o: scan_asn1SET.c asn1.h
scan_asn1STRING.o: scan_asn1STRING.c asn1.h
scan_asn1int.o: scan_asn1int.c asn1.h
scan_asn1length.o: scan_asn1length.c asn1.h
scan_asn1oid.o: scan_asn1oid.c asn1.h
scan_asn1rawint.o: scan_asn1rawint.c asn1.h
scan_asn1string.o: scan_asn1string.c asn1.h
scan_asn1tag.o: scan_asn1tag.c asn1.h
scan_ldapaddrequest.o: scan_ldapaddrequest.c asn1.h ldap.h
scan_ldapava.o: scan_ldapava.c asn1.h ldap.h
scan_ldapbindrequest.o: scan_ldapbindrequest.c asn1.h ldap.h
scan_ldapbindresponse.o: scan_ldapbindresponse.c asn1.h ldap.h
scan_ldapmessage.o: scan_ldapmessage.c asn1.h ldap.h
scan_ldapmodifyrequest.o: scan_ldapmodifyrequest.c asn1.h ldap.h
scan_ldapresult.o: scan_ldapresult.c asn1.h ldap.h
scan_ldapsearchfilter.o: scan_ldapsearchfilter.c asn1.h ldap.h
scan_ldapsearchfilterstring.o: scan_ldapsearchfilterstring.c ldap.h
scan_ldapsearchrequest.o: scan_ldapsearchrequest.c asn1.h ldap.h
scan_ldapsearchresultentry.o: scan_ldapsearchresultentry.c asn1.h ldap.h
scan_ldapstring.o: scan_ldapstring.c asn1.h ldap.h

6
auth.c
View File

@@ -19,14 +19,14 @@
int check_password(const char* fromdb,struct string* plaintext) {
if (str_start(fromdb,"{MD5}")) {
char digest[17];
unsigned char digest[17];
char md5[40];
MD5_CTX c;
MD5Init(&c);
MD5Update(&c,plaintext->s,plaintext->l);
MD5Update(&c,(unsigned char*)plaintext->s,plaintext->l);
MD5Final(digest,&c);
digest[16]=0;
md5[fmt_base64(md5,digest,16)]=0;
md5[fmt_base64(md5,(char*)digest,16)]=0;
if (str_equal(md5,fromdb+5))
return 1;
}

View File

@@ -8,7 +8,6 @@
#include "byte.h"
int main(int argc,char* argv[]) {
int verbose=0;
unsigned long filelen;
char* fn=argc<2?"data":argv[1];
char* map=mmap_read(fn,&filelen);
@@ -31,7 +30,7 @@ int main(int argc,char* argv[]) {
uint32 ofs,next;
acl_ofs=0;
for (ofs=indices_offset+record_count*4; ofs<(unsigned long)filelen;) {
uint32 index_type,next,indexed_attribute;
uint32 index_type;
uint32_unpack(map+ofs,&index_type);
uint32_unpack(map+ofs+4,&next);
if (index_type==2) { acl_ofs=ofs; break; }

3
ldap.h
View File

@@ -19,6 +19,7 @@ struct AttributeValueAssertion {
struct AttributeDescriptionList {
struct string a;
uint32 attrofs;
struct AttributeDescriptionList *next;
};
@@ -124,7 +125,7 @@ unsigned int scan_ldapava(const char* src,const char* max,struct AttributeValueA
unsigned int scan_ldapsearchfilter(const char* src,const char* max,struct Filter** f);
unsigned int scan_ldapsearchrequest(const char* src,const char* max,struct SearchRequest* s);
unsigned int scan_ldapsearchresultentry(const char* src,const char* max,struct SearchResultEntry* sre);
unsigned int scan_ldapresult(const char* src,const char* max,long* result,
unsigned int scan_ldapresult(const char* src,const char* max,unsigned long* result,
struct string* matcheddn,struct string* errormessage,
struct string* referral);
unsigned int scan_ldapmodifyrequest(const char* src,const char* max,struct ModifyRequest* m);

View File

@@ -15,7 +15,7 @@
#define BUFSIZE 8192
static long messageid=1;
static unsigned long messageid=1;
static int ldapbind(int sock) {
char outbuf[1024];
@@ -23,7 +23,7 @@ static int ldapbind(int sock) {
int len=fmt_ldapbindrequest(outbuf+s,3,"","");
int hlen=fmt_ldapmessage(0,messageid,BindRequest,len);
int res;
long op,Len,result;
unsigned long op,Len,result;
struct string matcheddn,errormessage,referral;
fmt_ldapmessage(outbuf+s-hlen,messageid,BindRequest,len);
if (write(sock,outbuf+s-hlen,len+hlen)!=len+hlen) return 0;;
@@ -48,6 +48,7 @@ int main(int argc,char* argv[]) {
++me;
else
me=argv[0];
n=1;
if ((bench=!strcmp(me,"ldapbench"))) {
n=atoi(getenv("NUM"));
buffer_putsflush(buffer_2,"benchmark mode\n");
@@ -58,7 +59,6 @@ usage:
buffer_putsflush(buffer_2,"usage: ldapclient ip baseObject filter [foo...]\n");
return 0;
}
if (!bench) n=1;
for (durchlauf=0; durchlauf<n; ++durchlauf) {
sock=socket_tcp4();
{
@@ -125,7 +125,7 @@ usage:
int matches=0;
len=0;
for (;;) {
long slen,mid,op;
unsigned long slen,mid,op;
int cur=0;
tmp=read(sock,buf+len,sizeof(buf)-len);

View File

@@ -12,7 +12,7 @@
#define BUFSIZE 8192
static long messageid=1;
static unsigned long messageid=1;
static int ldapbind(int sock) {
char outbuf[1024];
@@ -20,7 +20,7 @@ static int ldapbind(int sock) {
int len=fmt_ldapbindrequest(outbuf+s,3,"","");
int hlen=fmt_ldapmessage(0,messageid,BindRequest,len);
int res;
long op,Len,result;
unsigned long op,Len,result;
struct string matcheddn,errormessage,referral;
fmt_ldapmessage(outbuf+s-hlen,messageid,BindRequest,len);
if (write(sock,outbuf+s-hlen,len+hlen)!=len+hlen) return 0;;
@@ -98,7 +98,7 @@ usage:
char* max;
struct SearchResultEntry sre;
for (;;) {
long slen,mid,op;
unsigned long slen,mid,op;
tmp=read(sock,buf+len,sizeof(buf)-len);
if (tmp<=0) {
buffer_putsflush(buffer_2,"read error.\n");

View File

@@ -281,7 +281,7 @@ int ldif_parse(const char* filename) {
} else {
fd=open_read(filename);
if (fd<0) return 1;
buffer_init(&in,read,fd,buf,sizeof buf);
buffer_init(&in,(void*)read,fd,buf,sizeof buf);
tmp=&in;
}
dn=mduptab_adds(&attributes,"dn");

View File

@@ -13,16 +13,16 @@
#include "textcode.h"
int main(int argc,char* argv[]) {
char digest[17];
unsigned char digest[17];
char md5[40];
int i;
for (i=1; i<argc; ++i) {
MD5_CTX c;
MD5Init(&c);
MD5Update(&c,argv[i],str_len(argv[i]));
MD5Update(&c,(unsigned char*)argv[i],str_len(argv[i]));
MD5Final(digest,&c);
digest[16]=0;
md5[fmt_base64(md5,digest,16)]=0;
md5[fmt_base64(md5,(char*)digest,16)]=0;
buffer_puts(buffer_1,argv[i]);
buffer_puts(buffer_1," -> {MD5}");
buffer_puts(buffer_1,md5);

View File

@@ -161,7 +161,7 @@ int main(int argc,char* argv[]) {
goto derrout2;
}
buffer_init(&rbuf,write,rfd,recbuf,sizeof recbuf);
buffer_init(&rbuf,(void*)write,rfd,recbuf,sizeof recbuf);
ldif_parse_callback=ldif_callback;
@@ -175,7 +175,7 @@ derrout2:
return 1;
}
buffer_init(&outbuf,write,fd,buf,sizeof buf);
buffer_init(&outbuf,(void*)write,fd,buf,sizeof buf);
mduptab_init(&attributes);
mduptab_init(&classes);
@@ -249,7 +249,7 @@ writeerror:
buffer_flush(&rbuf);
if (lseek(rfd,0,SEEK_SET)!=0) diesys(1,"lseek failed");
buffer_init(&rbuf,read,rfd,recbuf,sizeof recbuf);
buffer_init(&rbuf,(void*)read,rfd,recbuf,sizeof recbuf);
for (i=0; i<record_count; ++i) {
char convbuf[8];

View File

@@ -2,11 +2,15 @@
unsigned int scan_asn1BOOLEAN(const char* src,const char* max,unsigned long* l) {
unsigned int tmp;
long tag;
unsigned long tag;
enum asn1_tagclass tc;
enum asn1_tagtype tt;
if ((tmp=scan_asn1int(src,max,&tc,&tt,&tag,l)))
if (tc==UNIVERSAL && tt==PRIMITIVE && tag==BOOLEAN)
long ltmp;
if ((tmp=scan_asn1int(src,max,&tc,&tt,&tag,&ltmp)))
if (tc==UNIVERSAL && tt==PRIMITIVE && tag==BOOLEAN) {
if (ltmp<0 || src+tmp+ltmp>max) return 0;
*l=(unsigned long)ltmp;
return tmp;
}
return 0;
}

View File

@@ -2,11 +2,15 @@
unsigned int scan_asn1ENUMERATED(const char* src,const char* max,unsigned long* l) {
unsigned int tmp;
long tag;
unsigned long tag;
enum asn1_tagclass tc;
enum asn1_tagtype tt;
if ((tmp=scan_asn1int(src,max,&tc,&tt,&tag,l)))
if (tc==UNIVERSAL && tt==PRIMITIVE && tag==ENUMERATED)
long ltmp;
if ((tmp=scan_asn1int(src,max,&tc,&tt,&tag,&ltmp)))
if (tc==UNIVERSAL && tt==PRIMITIVE && tag==ENUMERATED) {
if (ltmp<0 || src+tmp+ltmp>max) return 0;
*l=(unsigned long)ltmp;
return tmp;
}
return 0;
}

View File

@@ -2,7 +2,7 @@
unsigned int scan_asn1INTEGER(const char* src,const char* max,signed long* l) {
unsigned int tmp;
long tag;
unsigned long tag;
enum asn1_tagclass tc;
enum asn1_tagtype tt;
if ((tmp=scan_asn1int(src,max,&tc,&tt,&tag,l)))

View File

@@ -2,7 +2,7 @@
unsigned int scan_asn1SEQUENCE(const char* src,const char* max,unsigned long* len) {
unsigned int res,tmp;
long tag;
unsigned long tag;
enum asn1_tagclass tc;
enum asn1_tagtype tt;
if (!(res=scan_asn1tag(src,max,&tc,&tt,&tag))) return 0;

View File

@@ -2,7 +2,7 @@
unsigned int scan_asn1SET(const char* src,const char* max,unsigned long* len) {
unsigned int res,tmp;
long tag;
unsigned long tag;
enum asn1_tagclass tc;
enum asn1_tagtype tt;
if (!(res=scan_asn1tag(src,max,&tc,&tt,&tag))) return 0;

View File

@@ -2,7 +2,7 @@
unsigned int scan_asn1STRING(const char* src,const char* max,const char** s,unsigned long* l) {
unsigned int tmp;
long tag;
unsigned long tag;
enum asn1_tagclass tc;
enum asn1_tagtype tt;
if ((tmp=scan_asn1string(src,max,&tc,&tt,&tag,s,l)))

View File

@@ -2,7 +2,7 @@
unsigned int scan_asn1int(const char* src,const char* max,enum asn1_tagclass* tc,enum asn1_tagtype* tt,unsigned long* tag,signed long* l) {
unsigned int len,tmp;
long tlen;
unsigned long tlen;
if (!(len=scan_asn1tag(src,max,tc,tt,tag))) return 0;
if (!(tmp=scan_asn1length(src+len,max,&tlen))) return 0;
len+=tmp;

View File

@@ -17,7 +17,7 @@
unsigned int scan_ldapaddrequest(const char* src,const char* max,struct AddRequest* a) {
unsigned int res,tmp;
long oslen; /* outer sequence length */
unsigned long oslen; /* outer sequence length */
struct Addition* last=0;
a->a.next=0;
if (!(res=scan_ldapstring(src,max,&a->entry))) goto error;
@@ -27,7 +27,7 @@ unsigned int scan_ldapaddrequest(const char* src,const char* max,struct AddReque
max=src+res+oslen;
if (src+res>=max) goto error; /* need at least one record */
do {
long islen;
unsigned long islen;
if (last) {
struct Addition* cur;
if (!(cur=malloc(sizeof(struct Addition))))
@@ -48,7 +48,7 @@ unsigned int scan_ldapaddrequest(const char* src,const char* max,struct AddReque
/* scan set of AttributeValue: */
{
long set_len;
unsigned long set_len;
const char* set_max;
struct AttributeDescriptionList* ilast=0;
if (!(tmp=scan_asn1SET(src+res,max,&set_len))) {

View File

@@ -19,7 +19,7 @@
unsigned int scan_ldapmodifyrequest(const char* src,const char* max,struct ModifyRequest* m) {
unsigned int res,tmp;
long oslen; /* outer sequence length */
unsigned long oslen; /* outer sequence length */
struct Modification* last=0;
m->m.next=0;
if (!(res=scan_ldapstring(src,max,&m->object))) goto error;
@@ -29,7 +29,7 @@ unsigned int scan_ldapmodifyrequest(const char* src,const char* max,struct Modif
max=src+res+oslen;
if (src+res>=max) goto error; /* need at least one record */
do {
long islen, etmp;
unsigned long islen, etmp;
if (last) {
struct Modification* cur;
if (!(cur=malloc(sizeof(struct Modification)))) goto error;
@@ -42,7 +42,7 @@ unsigned int scan_ldapmodifyrequest(const char* src,const char* max,struct Modif
if (!(tmp=scan_asn1ENUMERATED(src+res,max,&etmp))) goto error;
if (etmp>2) goto error; last->operation=etmp; res+=tmp;
{
long iislen; /* urgh, _three_ levels of indirection */
unsigned long iislen; /* urgh, _three_ levels of indirection */
const char* imax;
if (!(tmp=scan_asn1SEQUENCE(src+res,max,&iislen))) goto error;
res+=tmp;
@@ -51,7 +51,7 @@ unsigned int scan_ldapmodifyrequest(const char* src,const char* max,struct Modif
if (!(tmp=scan_ldapstring(src+res,imax,&last->AttributeDescription))) goto error;
res+=tmp;
{
long iiislen; /* waah, _four_ levels of indirection! It doesn't get more inefficient than this */
unsigned long iiislen; /* waah, _four_ levels of indirection! It doesn't get more inefficient than this */
const char* iimax;
struct AttributeDescriptionList* ilast=0;
if (!(tmp=scan_asn1SET(src+res,max,&iiislen))) goto error;

View File

@@ -1,7 +1,7 @@
#include "asn1.h"
#include "ldap.h"
unsigned int scan_ldapresult(const char* src,const char* max,long* result,
unsigned int scan_ldapresult(const char* src,const char* max,unsigned long* result,
struct string* matcheddn,struct string* errormessage,
struct string* referral) {
unsigned int res,tmp;

View File

@@ -80,7 +80,7 @@ unsigned int scan_ldapsearchfilter(const char* src,const char* max,struct Filter
break;
case 4: /* substrings [4] SubstringFilter, */
{
long len2;
unsigned long len2;
if (!(tmp=scan_ldapstring(src+res,nmax,&(*f)->ava.desc))) goto error;
res+=tmp;
if (!(tmp=scan_asn1SEQUENCE(src+res,nmax,&len2))) goto error;

View File

@@ -6,6 +6,7 @@ unsigned int scan_ldapsearchrequest(const char* src,const char* max,
struct SearchRequest* s) {
unsigned int res,tmp;
unsigned long etmp;
signed long ltmp;
s->attributes=0;
s->filter=0;
if (!(res=scan_ldapstring(src,max,&s->baseObject))) goto error;
@@ -13,9 +14,11 @@ unsigned int scan_ldapsearchrequest(const char* src,const char* max,
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 (!(tmp=scan_asn1INTEGER(src+res,max,&s->sizeLimit))) goto error;
if (!(tmp=scan_asn1INTEGER(src+res,max,&ltmp)) || ltmp<0) goto error;
s->sizeLimit=(unsigned long)ltmp;
res+=tmp;
if (!(tmp=scan_asn1INTEGER(src+res,max,&s->timeLimit))) goto error;
if (!(tmp=scan_asn1INTEGER(src+res,max,&ltmp)) || ltmp<0) goto error;
s->timeLimit=(unsigned long)ltmp;
res+=tmp;
if (!(tmp=scan_asn1BOOLEAN(src+res,max,&s->typesOnly))) goto error;
res+=tmp;

View File

@@ -4,7 +4,7 @@
unsigned int scan_ldapsearchresultentry(const char* src,const char* max,struct SearchResultEntry* sre) {
unsigned int res,tmp;
long oslen; /* outer sequence length */
unsigned long oslen; /* outer sequence length */
struct PartialAttributeList** a=&sre->attributes;
*a=0;
if (!(res=scan_ldapstring(src,max,&sre->objectName))) goto error;
@@ -15,7 +15,7 @@ unsigned int scan_ldapsearchresultentry(const char* src,const char* max,struct S
while (src+res<max) {
struct string s;
struct AttributeDescriptionList* x;
long islen;
unsigned long islen;
const char* nmax;
if (!(tmp=scan_asn1SEQUENCE(src+res,max,&islen))) goto error;
res+=tmp; nmax=src+res+islen; if (nmax>max) goto error;

2
t1.c
View File

@@ -117,7 +117,7 @@ int parse_ldif(const char* filename) {
int fd=open_read(filename);
buffer in;
if (fd<0) return 1;
buffer_init(&in,read,fd,buf,sizeof buf);
buffer_init(&in,(void*)read,fd,buf,sizeof buf);
dn=strduptab_add(&tags,"dn");
mail=strduptab_add(&tags,"mail");
sn=strduptab_add(&tags,"sn");

8
t2.c
View File

@@ -86,7 +86,7 @@ int main(int argc,char* argv[]) {
unsigned long size;
// char* ldapsequence=mmap_read("req",&size);
char* ldapsequence=mmap_read(argc>1?argv[1]:"/tmp/ldap/127.000.000.001.00389-127.000.000.001.38433",&size);
long messageid, op, len;
unsigned long messageid, op, len;
int res;
unsigned long done=0;
while (done<size) {
@@ -97,7 +97,7 @@ int main(int argc,char* argv[]) {
case BindRequest:
puts(" >> BindRequest <<");
{
long version,method;
unsigned long version,method;
struct string name;
int tmp;
printf("scan_ldapbindrequest: %d\n",tmp=scan_ldapbindrequest(ldapsequence+done+res,ldapsequence+done+res+len,&version,&name,&method));
@@ -105,7 +105,7 @@ int main(int argc,char* argv[]) {
if (method==0) {
enum asn1_tagclass tc;
enum asn1_tagtype tt;
long tag;
unsigned long tag;
if (scan_asn1string(ldapsequence+done+res+tmp,ldapsequence+size,&tc,&tt,&tag,&name.s,&name.l) &&
tc==PRIVATE && tt==PRIMITIVE && tag==0)
printf("simple \"%.*s\"\n",(int)name.l,name.s);
@@ -182,7 +182,7 @@ int main(int argc,char* argv[]) {
case SearchResultDone:
puts(" >> SearchResultDone <<");
{
long result;
unsigned long result;
struct string matcheddn,errormessage,referral;
printf("scan_ldapresult: %d\n",
scan_ldapresult(ldapsequence+done+res,ldapsequence+done+res+len,

View File

@@ -25,6 +25,7 @@
#include <signal.h>
#include "uint16.h"
#include "acl.h"
#include <ctype.h>
#ifdef DEBUG
#include <sys/poll.h>
@@ -37,7 +38,7 @@
/* basic operation: the whole data file is mmapped read-only at the beginning and stays there. */
char* map; /* where the file is mapped */
long filelen; /* how many bytes are mapped (the whole file) */
unsigned long filelen; /* how many bytes are mapped (the whole file) */
uint32 magic,attribute_count,record_count,indices_offset,size_of_string_table;
/* these are the first values from the file, see the file "FORMAT"
* basic counts and offsets needed to calculate the positions of
@@ -106,6 +107,28 @@ static void fixup(struct Filter* f) {
if (f->next) fixup(f->next);
}
static void fixupadl(struct AttributeDescriptionList* a) {
while (a) {
char* x=map+5*4+size_of_string_table;
unsigned int i;
a->attrofs=0;
for (i=0; i<attribute_count; ++i) {
uint32 j=uint32_read(x);
if (!matchcasestring(&a->a,map+j)) {
a->attrofs=j;
break;
}
x+=4;
}
if (!a->attrofs) {
buffer_puts(buffer_2,"cannot find attribute \"");
buffer_put(buffer_2,a->a.s,a->a.l);
buffer_putsflush(buffer_2,"\"!\n");
}
a=a->next;
}
}
@@ -145,7 +168,7 @@ static void load_acls() {
uint32 ofs;
uint32 acl_ofs;
acl_ofs=0;
for (ofs=indices_offset+record_count*4; ofs<(unsigned long)filelen;) {
for (ofs=indices_offset+record_count*4; ofs<filelen;) {
uint32 index_type,next;
uint32_unpack(map+ofs,&index_type);
uint32_unpack(map+ofs+4,&next);
@@ -369,7 +392,7 @@ static int indexable(struct Filter* f) {
case GREATEQUAL:
{
uint32 ofs;
for (ofs=indices_offset+record_count*4; ofs<(unsigned long)filelen;) {
for (ofs=indices_offset+record_count*4; ofs<filelen;) {
uint32 index_type,next,indexed_attribute;
index_type=uint32_read(map+ofs);
next=uint32_read(map+ofs+4);
@@ -602,7 +625,7 @@ static int useindex(struct Filter* f,unsigned long* bitfield) {
if (f->type==EQUAL) { /* prefer a hash index if there is one */
uint32 ofs;
for (ofs=indices_offset+record_count*4; ofs<(unsigned long)filelen;) {
for (ofs=indices_offset+record_count*4; ofs<filelen;) {
uint32 index_type,next,indexed_attribute;
index_type=uint32_read(map+ofs);
next=uint32_read(map+ofs+4);
@@ -611,7 +634,7 @@ static int useindex(struct Filter* f,unsigned long* bitfield) {
if (!matchstring(&f->ava.desc,map+indexed_attribute)) {
uint32 hashtabsize=uint32_read(map+ofs+12);
uint32 hashtab=ofs+16;
uint32 hashval=f->attrflag&1?hash_tolower(f->ava.value.s,f->ava.value.l):hash(f->ava.value.s,f->ava.value.l);
uint32 hashval=f->attrflag&1?hash_tolower((unsigned char*)f->ava.value.s,f->ava.value.l):hash((unsigned char*)f->ava.value.s,f->ava.value.l);
uint32 hashofs=uint32_read(map+hashtab+(hashval%hashtabsize)*4);
if (hashofs==0) return 1;
if (hashofs<ofs)
@@ -674,7 +697,7 @@ static int useindex(struct Filter* f,unsigned long* bitfield) {
if (f->substrings->substrtype!=prefix) return 0;
{
uint32 ofs;
for (ofs=indices_offset+record_count*4; ofs<(unsigned long)filelen;) {
for (ofs=indices_offset+record_count*4; ofs<filelen;) {
uint32 index_type,next,indexed_attribute;
index_type=uint32_read(map+ofs);
next=uint32_read(map+ofs+4);
@@ -709,7 +732,7 @@ static int useindex(struct Filter* f,unsigned long* bitfield) {
case EQUAL:
{
uint32 ofs;
for (ofs=indices_offset+record_count*4; ofs<(unsigned long)filelen;) {
for (ofs=indices_offset+record_count*4; ofs<filelen;) {
uint32 index_type,next,indexed_attribute;
index_type=uint32_read(map+ofs);
next=uint32_read(map+ofs+4);
@@ -795,6 +818,7 @@ static void answerwith(uint32 ofs,struct SearchRequest* sr,long messageid,int ou
x+=4;
adl[i].a.s=map+j;
adl[i].a.l=strlen(map+j);
adl[i].attrofs=j;
adl[i].next=adl+i+1;
}
adl[attribute_count-2].next=0;
@@ -827,7 +851,8 @@ static void answerwith(uint32 ofs,struct SearchRequest* sr,long messageid,int ou
}
}
for (k=0; k<Acls[j]->attrs; ++k) {
if (Acls[j]->Attrs[k]==any_ofs || !matchstring(&adl->a,map+Acls[j]->Attrs[k])) {
/* if (Acls[j]->Attrs[k]==any_ofs || !matchstring(&adl->a,map+Acls[j]->Attrs[k])) { */
if (Acls[j]->Attrs[k]==any_ofs || adl->attrofs==Acls[j]->Attrs[k]) {
if (Acls[j]->may&acl_read) {
#if 0
printf("acl %u allowed serving attribute \"%.*s\"\n",j,(int)adl->a.l,adl->a.s);
@@ -845,8 +870,8 @@ static void answerwith(uint32 ofs,struct SearchRequest* sr,long messageid,int ou
}
if (ok) break;
}
if (ok==1) {
if (ok==1) {
uint32_unpack(map+ofs,&j);
#if 0
buffer_puts(buffer_2,"looking for attribute \"");
@@ -858,7 +883,8 @@ static void answerwith(uint32 ofs,struct SearchRequest* sr,long messageid,int ou
val=map+uint32_read(map+ofs+12);
else {
for (; i<j; ++i)
if (!matchstring(&adl->a,map+uint32_read(map+ofs+i*8))) {
/* if (!matchstring(&adl->a,map+uint32_read(map+ofs+i*8))) { */
if (adl->attrofs == uint32_read(map+ofs+i*8)) {
val=map+uint32_read(map+ofs+i*8+4);
++i;
break;
@@ -867,20 +893,22 @@ static void answerwith(uint32 ofs,struct SearchRequest* sr,long messageid,int ou
if (val) {
*pal=malloc(sizeof(struct PartialAttributeList));
if (!*pal) {
nomem:
nomem:
buffer_putsflush(buffer_2,"out of virtual memory!\n");
exit(1);
}
(*pal)->type=adl->a;
{
struct AttributeDescriptionList** a=&(*pal)->values;
add_attribute:
struct AttributeDescriptionList** a;
a=&(*pal)->values;
add_attribute:
*a=malloc(sizeof(struct AttributeDescriptionList));
if (!*a) goto nomem;
(*a)->a.s=bstrfirst(val);
(*a)->a.l=bstrlen(val);
for (;i<j; ++i)
if (!matchstring(&adl->a,map+uint32_read(map+ofs+i*8))) {
/* if (!matchstring(&adl->a,map+uint32_read(map+ofs+i*8))) { */
if (adl->attrofs == uint32_read(map+ofs+i*8)) {
val=map+uint32_read(map+ofs+i*8+4);
++i;
a=&(*a)->next;
@@ -937,12 +965,12 @@ static void answerwith(uint32 ofs,struct SearchRequest* sr,long messageid,int ou
* tinyldap does not complain if you don't unbind before hanging up.
*/
int handle(int in,int out) {
int len;
unsigned int len;
char buf[BUFSIZE];
for (len=0;;) {
int tmp=read(in,buf+len,BUFSIZE-len);
int res;
long messageid,op,Len;
unsigned long messageid,op,Len;
if (tmp==0) {
close(in);
if (in!=out) close(out);
@@ -965,7 +993,7 @@ int handle(int in,int out) {
switch (op) {
case BindRequest:
{
long version,method;
unsigned long version,method;
struct string name;
int tmp;
tmp=scan_ldapbindrequest(buf+res,buf+res+len,&version,&name,&method);
@@ -1100,6 +1128,7 @@ found:
}
#endif
fixup(sr.filter);
fixupadl(sr.attributes);
if (indexable(sr.filter)) {
unsigned long* result;
unsigned long i;