clean up warnings

This commit is contained in:
leitner
2024-10-21 16:02:34 +00:00
parent f85f30c379
commit 747641557e
7 changed files with 37 additions and 29 deletions

4
acl.c
View File

@@ -43,7 +43,7 @@ struct acl {
static unsigned long lines;
static stralloc x;
void parseerror() {
[[noreturn]] void parseerror() {
char buf[FMT_ULONG];
buf[fmt_ulong(buf,lines)]=0;
die(1,"parse error in line ",buf);
@@ -408,7 +408,7 @@ nomem:
/* now the ACLs */
A=malloc(sizeof(*A)*acls);
A=calloc(acls,sizeof(*A));
if (!A) goto nomem;
// acl_offset=F[i]+(acls+1)*sizeof(*A);

View File

@@ -249,7 +249,7 @@ int main(int argc,char* argv[]) {
}
}
if (!counted) die(111,"attribute does not occur?!");
y=malloc(counted*sizeof(struct node));
y=calloc(counted,sizeof(struct node));
if (!y) die(111,"out of memory");
x=map+5*4+size_of_string_table+attribute_count*8;
for (cur=i=0; i<record_count; ++i) {

View File

@@ -61,10 +61,9 @@ kaputt:
buffer_puts(buffer_1,"any");
else if (scan_ldapsearchfilter(map+ofs,map+filelen,&f)!=0) {
unsigned long l=fmt_ldapsearchfilterstring(0,f);
unsigned long l2;
char* buf=malloc(l+23);
if (!buf) goto kaputt;
buf[l2=fmt_ldapsearchfilterstring(buf,f)]=0;
buf[fmt_ldapsearchfilterstring(buf,f)]=0;
buffer_puts(buffer_1,buf);
free_ldapsearchfilter(f);
free(f);

View File

@@ -9,6 +9,7 @@
#include <libowfat/ip4.h>
#include <libowfat/str.h>
#include <libowfat/textcode.h>
#include <alloca.h>
#include <fcntl.h>
#include <sys/socket.h>
@@ -183,15 +184,9 @@ nextmessage:
max=buf+cur+slen+tmp2;
if (op==SearchResultEntry) {
++matches;
if ((tmp=scan_ldapsearchresultentry(buf+cur+tmp2,max,&sre))) {
if (scan_ldapsearchresultentry(buf+cur+tmp2,max,&sre)) {
struct PartialAttributeList* pal=sre.attributes;
#if 0
buffer_puts(buffer_2,"DEBUG: sre size ");
buffer_putulong(buffer_2,tmp);
buffer_putsflush(buffer_2,".\n");
#endif
if (durchlauf==0) {
buffer_puts(buffer_1,"dn: ");
buffer_putescaped(buffer_1,sre.objectName.s,sre.objectName.l);

View File

@@ -78,7 +78,7 @@ size_t scan_ldapaddrequest(const char* src,const char* max,struct AddRequest* a)
ilast->next=x;
ilast = ilast->next;
} else {
ilast=&last->vals;
ilast = &last->vals;
}
ilast->next=0;
if (!(tmp=scan_ldapstring(src+res,max,&ilast->a))) // fail11

View File

@@ -4,7 +4,7 @@
size_t scan_ldapsearchfilterstring(const char* src,struct Filter** f) {
char* s=(char*)src;
if (!(*f=calloc(sizeof(struct Filter),1))) goto error;
if (!(*f=calloc(1,sizeof(struct Filter)))) return 0;
if (s[0]=='*' && (s[1]==0 || s[1]=='(')) {
size_t i=scan_ldapsearchfilterstring("(objectClass=*)",f);
if (i) return 1;
@@ -96,5 +96,6 @@ substring:
}
return s-src+1;
error:
free_ldapsearchfilter(*f);
return 0;
}

View File

@@ -702,7 +702,7 @@ static void tagmatches(uint32* index,size_t elements,struct string* s,
if (mid) /* thx Andreas Stührk */
for (k=mid-1; k!=(uint32_t)-1; --k) {
m=uint32_read((char*)(&index[k]));
if ((ft==LESSEQUAL) || (l=match(s,map+m))==0) {
if ((ft==LESSEQUAL) || match(s,map+m)==0) {
if (index_type==0)
rec=findrec(m);
else if (index_type==1)
@@ -713,7 +713,7 @@ static void tagmatches(uint32* index,size_t elements,struct string* s,
}
for (k=mid+1; k<elements; ++k) {
m=uint32_read((char*)(&index[k]));
if ((ft==GREATEQUAL) || (l=match(s,map+m))==0) {
if ((ft==GREATEQUAL) || match(s,map+m)==0) {
if (index_type==0)
rec=findrec(m);
else if (index_type==1)
@@ -837,6 +837,7 @@ static int useindex(struct Filter* f,struct bitfield* b) {
struct bitfield tmp;
int ok=0;
tmp.bits=alloca(record_set_length*sizeof(unsigned long));
memset(tmp.bits,0,record_set_length*sizeof(unsigned long));
if (y) {
useindex(y,b);
y=y->next;
@@ -860,6 +861,7 @@ static int useindex(struct Filter* f,struct bitfield* b) {
struct bitfield tmp;
int ok=1;
tmp.bits=alloca(record_set_length*sizeof(unsigned long));
memset(tmp.bits,0,record_set_length*sizeof(unsigned long));
if (y) {
useindex(y,b);
y=y->next;
@@ -1300,8 +1302,7 @@ static int addreq2sre(struct SearchResultEntry* sre,struct AddRequest* ar) {
static int mr2sreh1(struct PartialAttributeList** dest,struct Modification* src) {
*dest=0;
while (src) {
if (!(*dest=malloc(sizeof(**dest)))) return -1;
byte_zero(*dest,sizeof(**dest));
if (!(*dest=calloc(1,sizeof(**dest)))) return -1;
(*dest)->type=src->AttributeDescription;
if (copyadl2(&(*dest)->values,src->vals)) return -1;
dest=&(*dest)->next;
@@ -1317,8 +1318,7 @@ static int mr2sreh1(struct PartialAttributeList** dest,struct Modification* src)
static int modreq2sre(struct SearchResultEntry* sre,struct ModifyRequest* mr) {
byte_zero(sre,sizeof(*sre));
sre->objectName=mr->object;
if (!(sre->attributes=malloc(sizeof(*sre->attributes))) ||
mr2sreh1(&sre->attributes,&mr->m)) {
if (mr2sreh1(&sre->attributes,&mr->m)) {
free_ldapsearchresultentry(sre);
return -1;
}
@@ -1465,6 +1465,7 @@ static int lookupdn(struct string* dn,size_t* index, struct hashnode** hn) {
struct bitfield result;
size_t i;
result.bits=alloca(record_set_length*sizeof(unsigned long));
memset(result.bits,0,record_set_length*sizeof(unsigned long));
if (!useindex(&f,&result) || result.first>result.last)
return 0;
// assert(result.last<=record_count);
@@ -1533,6 +1534,7 @@ void reply_with_index(struct SearchRequest* sr,unsigned long* messageid,int out)
if (debug) buffer_putsflush(buffer_2,"query can be answered with index!\n");
#endif
result.bits=alloca(record_set_length*sizeof(unsigned long));
memset(result.bits,0,record_set_length*sizeof(unsigned long));
/* Use the index to find matching data. Put the offsets
* of the matches in a table. Use findrec to locate
* the records that point to the data. */
@@ -1715,7 +1717,12 @@ static int handle(int in,int out) {
struct hashnode* hn;
int err=success;
scan_ldapstring(buf+res+tmp,buf+len,&password);
enum asn1_tagclass tc;
enum asn1_tagtype tt;
unsigned long tag;
if (scan_asn1string(buf+res+tmp-1,buf+len,&tc,&tt,&tag,&password.s,&password.l)==0) {
password.l=0; password.s=0;
}
normalize_string_dn(&name);
switch (lookupdn(&name,&idx,&hn)) {
@@ -1724,9 +1731,14 @@ static int handle(int in,int out) {
case 0: err=noSuchObject; break;
default: err=operationsError;
}
if (err!=success)
if (err!=success) {
if (verbose) {
buffer_puts(buffer_2,"lookupdn(\"");
buffer_put(buffer_2,name.s,name.l);
buffer_putsflush(buffer_2,"\") failed\n");
}
goto authfailure;
else {
} else {
const char* c=0;
uint32 authdn=0;
char* authdn_str=0;
@@ -1746,7 +1758,9 @@ static int handle(int in,int out) {
authdn_str=(char*)map+authdn;
authdn=j;
if (!(j=ldap_find_attr_value(j,userPassword_ofs))) {
buffer_putsflush(buffer_2,"no userPassword attribute found, bind failed!\n");
if (verbose) {
buffer_putsflush(buffer_2,"no userPassword attribute found, bind failed!\n");
}
goto authfailure;
}
c=map+j;
@@ -1796,7 +1810,6 @@ authfailure:
case SearchRequest:
{
struct SearchRequest sr;
size_t tmp;
#if 0
{
int fd=open_write("request");
@@ -1804,7 +1817,7 @@ authfailure:
close(fd);
}
#endif
if ((tmp=scan_ldapsearchrequest(buf+res,buf+len,&sr))) {
if (scan_ldapsearchrequest(buf+res,buf+len,&sr)) {
size_t returned=0;
#if (debug != 0)
@@ -1872,9 +1885,9 @@ authfailure:
case ModifyRequest:
{
struct ModifyRequest mr;
size_t tmp,err=success;
size_t err=success;
buffer_putsflush(buffer_2,"modifyrequest!\n");
if ((tmp=scan_ldapmodifyrequest(buf+res,buf+len,&mr))) {
if (scan_ldapmodifyrequest(buf+res,buf+len,&mr)) {
struct SearchResultEntry sre;
if (verbose) {
buffer_puts(buffer_1,"modify request: dn \"");
@@ -1977,7 +1990,7 @@ modreqerror:
int err=success;
struct AddRequest ar;
// buffer_putsflush(buffer_2,"AddRequest!\n");
if ((tmp=scan_ldapaddrequest(buf+res,buf+len,&ar))) {
if (scan_ldapaddrequest(buf+res,buf+len,&ar)) {
struct SearchResultEntry sre;
normalize_string_dn(&ar.entry);
/* convert addrequest to searchresultentry */