1From 898e9514bc889b4a540f667efed95a5af101c824 Mon Sep 17 00:00:00 2001 2From: Li xin <lixin.fnst@cn.fujitsu.com> 3Date: Tue, 2 Dec 2014 07:00:36 +0900 4Subject: [PATCH 1/3] From debian to fix compile errors 5 6Signed-off-by: Li Xin <lixin.fnst@cn.fujitsu.com> 7--- 8 src/Makefile.0 | 7 +++---- 9 src/autoconf | 64 +++++++++++++------------------------------------------- 10 src/comsat.c | 65 +++++++++++++++++++-------------------------------------- 11 src/fields.c | 6 +++--- 12 src/foldinfo.h | 2 +- 13 src/formail.c | 6 +++--- 14 src/formisc.c | 2 +- 15 src/formisc.h | 2 +- 16 src/mailfold.c | 14 ++++++++++--- 17 src/manconf.c | 2 +- 18 src/memblk.c | 24 ++++++++++----------- 19 src/memblk.h | 2 +- 20 src/network.h | 10 ++------- 21 src/pipes.c | 10 ++++----- 22 src/procmail.c | 3 +-- 23 src/recommend.c | 2 +- 24 16 files changed, 81 insertions(+), 140 deletions(-) 25 26diff --git a/src/Makefile.0 b/src/Makefile.0 27index 6eb5b51..15a2039 100644 28--- a/src/Makefile.0 29+++ b/src/Makefile.0 30@@ -40,7 +40,7 @@ multigram: multigram.$(O) $(MG_OBJ) setid 31 @cd ..; $(MAKE) config.check 32 33 _autotst: _autotst.$(O) sublib.c sublib.h 34- $(CC) $(CFLAGS) $@.$(O) -o $@ $(LDFLAGS) 35+ gcc $@.$(O) -o $@ $(LDFLAGS) 36 37 ../autoconf.h: autoconf Makefile ../patchlevel.h 38 @echo No this was not make -n >make_n 39@@ -175,17 +175,16 @@ recommend: recommend.$(O) sublib.$(O) 40 41 ../man/man.sed: manconf.c ../autoconf.h ../config.h includes.h procmail.h 42 ../man/man.sed: ../patchlevel.h 43- @$(CC) $(CFLAGS) "-DBINDIR=\"$(VISIBLE_BINDIR)\"" -o _autotst \ 44+ gcc "-DBINDIR=\"$(VISIBLE_BINDIR)\"" -o _autotst \ 45 manconf.c $(LDFLAGS) 46 @./_autotst $@ 47 @echo Housekeeping file >$@ 48- @$(RM) _autotst 49 50 clean: 51 $(RM) -r _locktest 52 $(RM) procmail.$(O) $(PM_OBJ) lockfile.$(O) $(LF_OBJ) formail.$O \ 53 $(FM_OBJ) multigram.$(O) $(MG_OBJ) $(BINSS) multigram ../autoconf.h \ 54- _autotst* lookfor _locktst* grepfor recommend recommend.$(O) manconf \ 55+ lookfor _locktst* grepfor recommend recommend.$(O) manconf \ 56 _Makefile lock.log *core* targetdir.h setid setid.$(O) gethome \ 57 gethome.$(O) make_n realloc.log 58 59diff --git a/src/autoconf b/src/autoconf 60index 1cb4c42..ff78048 100755 61--- a/src/autoconf 62+++ b/src/autoconf 63@@ -68,8 +68,6 @@ 64 # #define NOfsync 65 #Ok #define endpwent() 66 #Ok #define endgrent() 67-#Ok #define endhostent() 68-#Ok #define endservent() 69 #Ok #define endprotoent() 70 # #define h_0addr_list h_addr 71 #Ok #define NOpw_passwd 72@@ -896,7 +894,7 @@ int main(){int i=0; 73 {uid_t vuid_t;i+=vuid_t=1;} 74 {gid_t vgid_t;i+=vgid_t=1;} 75 #ifndef NO_COMSAT 76- {struct hostent vhostent;i+=!(vhostent.h_addr_list=0);} 77+ {struct addrinfo res; i+=!(res.ai_socktype=0);} 78 #endif 79 #ifndef NOuname 80 {struct utsname vutsname;i+=!(*vutsname.nodename='\0');} 81@@ -917,8 +915,6 @@ do 82 test -z "$i3" && grepfor mode_t 'typedef int mode_t;' && i3=I 83 test -z "$i4" && grepfor uid_t 'typedef int uid_t;' && i4=I 84 test -z "$i5" && grepfor gid_t 'typedef int gid_t;' && i5=I 85- test -z "$i6" && grepfor h_addr_list '#define h_0addr_list h_addr' && i6=I 86- test -z "$i6" && grepfor hostent '#define h_0addr_list h_addr' && i6=I 87 test -z "$i6" && grepfor member '#define h_0addr_list h_addr' && i6=I 88 test -z "$i7" && grepfor utsname "#define NOuname \ 89 /* <sys/utsname.h> is there, but empty */" && i7=I 90@@ -1048,8 +1044,12 @@ int main(){char a[2]; 91 {struct utsname b;uname(&b);} 92 #endif 93 #ifndef NO_COMSAT 94- gethostbyname("0");getprotobyname(COMSATprotocol);endhostent();endservent(); 95- endprotoent(); 96+ { 97+ struct addrinfo *res, hints; 98+ memset(&hints, '\0', sizeof(hints)); 99+ if(getaddrinfo(COMSAThost,BIFF_serviceport,&hints,&res)) 100+ freeaddrinfo(res); 101+ } 102 #endif 103 _exit(0); 104 return 0;} 105@@ -1103,14 +1103,9 @@ grepfor uname "\ 106 /* <sys/utsname.h> defines it, the libraries don't */" 107 grepfor endpwent '#define endpwent()' 108 grepfor endgrent '#define endgrent()' 109-if grepfor gethostbyname '#define NO_COMSAT' 110+if grepfor getaddrinfo '#define NO_COMSAT' 111 then 112 : 113-else 114- grepfor getprotobyname '#define UDP_protocolno 17' 115- grepfor endhostent '#define endhostent()' 116- grepfor endservent '#define endservent()' 117- grepfor endprotoent '#define endprotoent()' 118 fi 119 grepfor strstr '#define SLOWstrstr' || 120 grepfor clock '#define SLOWstrstr' 121@@ -1239,39 +1234,9 @@ int main(argc,argv)int argc;const char*argv[]; 122 printf("/* Insufficient memory to perform the benchmark! */\n"); 123 #endif /* SLOWstrstr */ 124 #ifndef NO_COMSAT 125-#ifndef UDP_protocolno 126- ;{ const struct protoent*p; 127- if(p=getprotobyname(COMSATprotocol)) 128- { printf("#define UDP_protocolno %d\n",p->p_proto); 129-#else 130- ;{ if(1) 131- { 132-#endif 133- ;{ const struct servent*serv; 134- if(serv=getservbyname(COMSATservice,COMSATprotocol)) 135- printf("#define BIFF_serviceport \"%d\"\n", 136- ntohs(serv->s_port)); 137- } 138-#ifdef AF_INET 139- ;{ const struct hostent*host; 140- if(!strcmp("localhost",COMSAThost)&& 141- (host=gethostbyname(COMSAThost))&& 142- host->h_0addr_list&&host->h_addrtype==AF_INET&& 143- host->h_length) 144- { int j=host->h_length; 145- const unsigned char*ad=(void*)host->h_0addr_list; 146- printf("#define IP_localhost {"); 147- printf("%d",*ad++); 148- while(--j) 149- printf(",%d",*ad++); 150- puts("}"); 151- } 152- } 153+#ifndef AF_INET 154+ puts("#define NO_COMSAT"); 155 #endif /* AF_INET */ 156- } 157- else 158- puts("#define NO_COMSAT"); 159- } 160 #endif /* NO_COMSAT */ 161 ;{ unsigned long s=(size_t)~0;int bits; 162 for(bits=1;s>>=1;bits++); 163@@ -1470,15 +1435,14 @@ cat /usr/lib/sendmail.cf /etc/sendmail.cf /etc/mail/sendmail.cf 2>$DEVNULL | 164 grep 'Mlocal.*procmail' >$DEVNULL || 165 echo '#define CF_no_procmail_yet' >>$ACONF 166 167-cat /usr/lib/sendmail.cf /etc/sendmail.cf /etc/mail/sendmail.cf 2>$DEVNULL | 168- grep '^V' >$DEVNULL || 169- echo '#define buggy_SENDMAIL' >>$ACONF 170+# cat /usr/lib/sendmail.cf /etc/sendmail.cf /etc/mail/sendmail.cf 2>$DEVNULL | 171+# grep '^V' >$DEVNULL || 172+# echo '#define buggy_SENDMAIL' >>$ACONF 173 174 lpath='/bin' 175 bins="/bin" 176 177-for newd in /usr/bin /usr/ucb /usr/5bin $BINDIR /local/bin /usr/local/bin \ 178- /global/bin /usr/bin/X11 /usr/X*/bin 179+for newd in /usr/bin $BINDIR /usr/bin/X11 /usr/X*/bin 180 do 181 if test -d $newd 182 then 183diff --git a/src/comsat.c b/src/comsat.c 184index 77dba34..5082b16 100644 185--- a/src/comsat.c 186+++ b/src/comsat.c 187@@ -27,7 +27,8 @@ static /*const*/char rcsid[]= 188 #include "comsat.h" 189 190 static int csvalid; /* is it turned on with a good address? */ 191-static struct sockaddr_in csaddr; 192+static struct addrinfo cai; 193+static struct sockaddr *csaddr; 194 static char*cslastf,*cslgname; 195 196 void setlfcs(folder)const char*folder; /* set lastfolder for comsat */ 197@@ -62,56 +63,32 @@ void setlgcs(name)const char*name; /* set logname for comsat */ 198 } 199 200 int setcomsat(chp)const char*chp; 201-{ char*chad;int newvalid; struct sockaddr_in newaddr; 202+{ char*chad;int newvalid; struct addrinfo *res, hints; 203 chad=strchr(chp,SERV_ADDRsep); /* @ separator? */ 204 if(!chad&&!renvint(-1L,chp)) 205 return csvalid=0; /* turned off comsat */ 206 newvalid=1; 207 if(chad) 208 *chad++='\0'; /* split the specifier */ 209+ if(!chad||!*chp) /* no service */ 210+ chp=BIFF_serviceport; /* new balls please! */ 211 if(!chad||!*chad) /* no host */ 212-#ifndef IP_localhost /* Is "localhost" preresolved? */ 213 chad=COMSAThost; /* nope, use default */ 214-#else /* IP_localhost */ 215- { static const unsigned char ip_localhost[]=IP_localhost; 216- newaddr.sin_family=AF_INET; 217- tmemmove(&newaddr.sin_addr,ip_localhost,sizeof ip_localhost); 218- } 219- else 220-#endif /* IP_localhost */ 221- { const struct hostent*host; /* what host? paranoid checks */ 222- if(!(host=gethostbyname(chad))||!host->h_0addr_list) 223- { bbzero(&newaddr.sin_addr,sizeof newaddr.sin_addr); 224- newvalid=0; /* host can't be found, too bad */ 225- } 226- else 227- { newaddr.sin_family=host->h_addrtype; /* address number found */ 228- tmemmove(&newaddr.sin_addr,host->h_0addr_list,host->h_length); 229- } 230- endhostent(); 231- } 232- if(newvalid) /* so far, so good */ 233- { int s; 234- if(!*chp) /* no service */ 235- chp=BIFF_serviceport; /* new balls please! */ 236- s=strtol(chp,&chad,10); 237- if(chp!=chad) /* the service is not numeric */ 238- newaddr.sin_port=htons((short)s); /* network order */ 239- else 240- { const struct servent*serv; 241- serv=getservbyname(chp,COMSATprotocol); /* so get its no. */ 242- if(serv) 243- newaddr.sin_port=serv->s_port; 244- else 245- { newaddr.sin_port=htons((short)0); /* no such service */ 246- newvalid=0; 247- } 248- endservent(); 249- } 250- } 251+ bzero(&hints,sizeof(hints)); 252+ hints.ai_socktype=SOCK_DGRAM; 253+ hints.ai_flags=AI_ADDRCONFIG; 254+ if(getaddrinfo(chad,chp,&hints,&res)) 255+ newvalid=0; 256+ 257 onguard(); /* update the address atomically */ 258 if(csvalid=newvalid) 259- tmemmove(&csaddr,&newaddr,sizeof(newaddr)); 260+ { if(csaddr) 261+ free(csaddr); 262+ csaddr=malloc(res->ai_addrlen); 263+ tmemmove(csaddr,res->ai_addr,res->ai_addrlen); 264+ tmemmove(&cai,res,sizeof(cai)); 265+ freeaddrinfo(res); 266+ } 267 offguard(); 268 return newvalid; 269 } 270@@ -120,7 +97,7 @@ void sendcomsat(folder)const char*folder; 271 { int s;const char*p; 272 if(!csvalid||!buf) /* is comat on and set to a valid address? */ 273 return; 274- if(!*cslgname||strlen(cslgname)+2>linebuf) /* is $LOGNAME bogus? */ 275+ if(!cslgname||!*cslgname||strlen(cslgname)+2>linebuf)/* is $LOGNAME bogus? */ 276 return; 277 if(!(p=folder?folder:cslastf)) /* do we have a folder? */ 278 return; 279@@ -132,8 +109,8 @@ void sendcomsat(folder)const char*folder; 280 } 281 strlcat(buf,COMSATxtrsep,linebuf); /* custom seperator */ 282 strlcat(buf,p,linebuf); /* where was it delivered? */ 283- if((s=socket(AF_INET,SOCK_DGRAM,UDP_protocolno))>=0) 284- { sendto(s,buf,strlen(buf),0,(struct sockaddr*)&csaddr,sizeof(csaddr)); 285+ if((s=socket(cai.ai_family,cai.ai_socktype,cai.ai_protocol))>=0) 286+ { sendto(s,buf,strlen(buf),0,csaddr,cai.ai_addrlen); 287 rclose(s); 288 yell("Notified comsat:",buf); 289 } 290diff --git a/src/fields.c b/src/fields.c 291index a2bd77f..37ed154 100644 292--- a/src/fields.c 293+++ b/src/fields.c 294@@ -110,16 +110,16 @@ void dispfield(p)register const struct field*p; 295 /* try and append one valid field to rdheader from stdin */ 296 int readhead P((void)) 297 { int idlen; 298- getline(); 299+ get_line(); 300 if((idlen=breakfield(buf,buffilled))<=0) /* not the start of a valid field */ 301 return 0; 302 if(idlen==STRLEN(FROM)&&eqFrom_(buf)) /* it's a From_ line */ 303 { if(rdheader) 304 return 0; /* the From_ line was a fake! */ 305- for(;buflast=='>';getline()); /* gather continued >From_ lines */ 306+ for(;buflast=='>';get_line()); /* gather continued >From_ lines */ 307 } 308 else 309- for(;;getline()) /* get the rest of the continued field */ 310+ for(;;get_line()) /* get the rest of the continued field */ 311 { switch(buflast) /* will this line be continued? */ 312 { case ' ':case '\t': /* yep, it sure is */ 313 continue; 314diff --git a/src/foldinfo.h b/src/foldinfo.h 315index 9e4ebb6..797f9be 100644 316--- a/src/foldinfo.h 317+++ b/src/foldinfo.h 318@@ -10,7 +10,7 @@ 319 320 #define ft_lock(type) ((type)>ft_MAILDIR) /* kernel lock fd */ 321 #define ft_atime(type) ((type)==ft_FILE) /* force atime < mtime */ 322-#define ft_dotlock(type) ((type)==ft_FILE) /* dotlock $DEFAULT */ 323+#define ft_dotlock(type) ((type)>ft_MAILDIR) /* dotlock $DEFAULT */ 324 #define ft_delim(type) ((type)==ft_FILE) /* add MMDF delim */ 325 #define ft_checkcloser(type) ((type)>ft_MH) 326 #define ft_forceblank(type) ((type)!=ft_MAILDIR) /* force blank line at end */ 327diff --git a/src/formail.c b/src/formail.c 328index fe5e6be..1f5c9dd 100644 329--- a/src/formail.c 330+++ b/src/formail.c 331@@ -758,9 +758,9 @@ startover: 332 lputssn(buf,buffilled),ctlength-=buffilled,buffilled=lnl=0; 333 ;{ int tbl=buflast,lwr='\n'; 334 while(--ctlength>=0&&tbl!=EOF) /* skip Content-Length: bytes */ 335- lnl=lwr==tbl&&lwr=='\n',putcs(lwr=tbl),tbl=getchar(); 336+ lnl=lwr==tbl&&lwr=='\n',lputcs(lwr=tbl),tbl=getchar(); 337 if((buflast=tbl)=='\n'&&lwr!=tbl) /* just before a line break? */ 338- putcs('\n'),buflast=getchar(); /* wrap up loose end */ 339+ lputcs('\n'),buflast=getchar(); /* wrap up loose end */ 340 } 341 if(!quiet&&ctlength>0) 342 { charNUM(num,ctlength); 343@@ -819,7 +819,7 @@ splitit: { if(!lnl) /* did the previous mail end with an empty line? */ 344 { if(split) /* gobble up the next start separator */ 345 { buffilled=0; 346 #ifdef sMAILBOX_SEPARATOR 347- getline();buffilled=0; /* but only if it's defined */ 348+ get_line();buffilled=0; /* but only if it's defined */ 349 #endif 350 if(buflast!=EOF) /* if any */ 351 goto splitit; 352diff --git a/src/formisc.c b/src/formisc.c 353index d6cab90..338733b 100644 354--- a/src/formisc.c 355+++ b/src/formisc.c 356@@ -115,7 +115,7 @@ void loadchar(c)const int c; /* append one character to buf */ 357 buf[buffilled++]=c; 358 } 359 360-int getline P((void)) /* read a newline-terminated line */ 361+int get_line P((void)) /* read a newline-terminated line */ 362 { if(buflast==EOF) /* at the end of our Latin already? */ 363 { loadchar('\n'); /* fake empty line */ 364 return EOF; /* spread the word */ 365diff --git a/src/formisc.h b/src/formisc.h 366index 1c4ca20..f25211c 100644 367--- a/src/formisc.h 368+++ b/src/formisc.h 369@@ -17,4 +17,4 @@ void 370 char* 371 skipwords P((char*start)); 372 int 373- getline P((void)); 374+ get_line P((void)); 375diff --git a/src/mailfold.c b/src/mailfold.c 376index 917b502..6c8bcf4 100644 377--- a/src/mailfold.c 378+++ b/src/mailfold.c 379@@ -30,6 +30,7 @@ static /*const*/char rcsid[]= 380 381 int logopened,rawnonl; 382 off_t lasttell; 383+static int trunced; 384 static long lastdump; 385 static volatile int mailread; /* if the mail is completely read in already */ 386 static struct dyna_array confield; /* escapes, concatenations */ 387@@ -81,6 +82,7 @@ long dump(s,type,source,len)const int s,type;const char*source; 388 long len; 389 { int i;long part; 390 lasttell=i= -1;SETerrno(EBADF); 391+ trunced=0; 392 if(s>=0) 393 { if(ft_lock(type)&&(lseek(s,(off_t)0,SEEK_END),fdlock(s))) 394 nlog("Kernel-lock failed\n"); 395@@ -120,13 +122,18 @@ jin: while(part&&(i=rwrite(s,source,BLKSIZ<part?BLKSIZ:(int)part))) 396 } 397 writefin: 398 i=type!=ft_PIPE&&fsync(s)&&errno!=EINVAL; /* EINVAL => wasn't a file */ 399+ if ((i||len)&&lasttell>=0) 400+ { int serrno=errno; 401+ if(!ftruncate(s,lasttell)) trunced=1; 402+ SETerrno(serrno); 403+ } 404 if(ft_lock(type)) 405 { int serrno=errno; /* save any error information */ 406 if(fdunlock()) 407 nlog("Kernel-unlock failed\n"); 408 SETerrno(serrno); 409 } 410- i=rclose(s)||i; 411+ i=rclose(s)||i; /* if this fails, we should truncate, but it's too late */ 412 } /* return an error even if nothing was to be sent */ 413 return i&&!len?-1:len; 414 } 415@@ -237,7 +244,7 @@ dumpf: { switch(errno) 416 #endif 417 default:writeerr(buf); 418 } 419- if(lasttell>=0&&!truncate(boxname,lasttell)&&(logopened||verbose)) 420+ if(lasttell>=0&&trunced&&(logopened||verbose)) 421 nlog("Truncated file to former size\n"); /* undo garbage */ 422 ret0: return 0; 423 } 424@@ -378,7 +385,8 @@ void readmail(rhead,tobesent)const long tobesent; 425 dfilled=mailread=0; 426 else if(rhead) /* only read in a new header */ 427 { memblk new; 428- dfilled=mailread=0;makeblock(&new,0);readdyn(&new,&dfilled,0); 429+ dfilled=mailread=0;makeblock(&new,0); 430+ readdyn(&new,&dfilled,thebody-themail.p); 431 if(tobesent>dfilled&&isprivate) /* put it in place here */ 432 { tmemmove(themail.p+dfilled,thebody,filled-=tobesent); 433 tmemmove(themail.p,new.p,dfilled); 434diff --git a/src/manconf.c b/src/manconf.c 435index a9e9f1c..5c8ec36 100644 436--- a/src/manconf.c 437+++ b/src/manconf.c 438@@ -233,7 +233,7 @@ a security violation was found (e.g. \1.B \2-@PRESERVOPT@\1or variable\ 439 \2-@PRESERVOPT@\1and\1.BR \2-@FROMWHOPT@ .\1"); 440 pc("LMTPOPT",LMTPOPT); 441 #else 442- ps("LMTPOPTdesc","");ps("LMTPusage",""); 443+ ps("LMTPOPTdesc","");ps("LMTPusage","\1"); 444 #endif 445 pname("INIT_UMASK",0);printf("0%lo/g\n",(unsigned long)INIT_UMASK);lines--; 446 pn("DEFlinebuf",DEFlinebuf); 447diff --git a/src/memblk.c b/src/memblk.c 448index e2f13f0..97e02d3 100644 449--- a/src/memblk.c 450+++ b/src/memblk.c 451@@ -51,11 +51,11 @@ void lockblock(mb)memblk*const mb; 452 { 453 #ifdef USE_MMAP 454 if(mb->fd>=0) 455- { long len=mb->len+1; 456- if(munmap(mb->p,len)) 457- mmapfailed(len); /* don't want to continue here */ 458- if((mb->p=mmap(0,len,PROT_READ,MAP_PRIVATE,mb->fd,(off_t)0))==MAP_FAILED) 459- mmapfailed(len); 460+ { long mlen=mb->len+1; 461+ if(munmap(mb->p,mlen)) 462+ mmapfailed(mlen); /* don't want to continue here */ 463+ if((mb->p=mmap(0,mlen,PROT_READ,MAP_PRIVATE,mb->fd,(off_t)0))==MAP_FAILED) 464+ mmapfailed(mlen); 465 close(mb->fd); 466 mb->fd=ropen(devnull,O_RDWR,0); /* XXX Perhaps -1 is better? */ 467 } 468@@ -77,8 +77,8 @@ int resizeblock(mb,len,nonfatal)memblk*const mb;const long len; 469 strcpy(filename,MMAP_DIR); 470 if(unique(filename,strchr(filename,'\0'),MMAP_FILE_LEN,MMAP_PERM,0,0)&& 471 (mb->fd=ropen(filename,O_RDWR,MMAP_PERM),unlink(filename),mb->fd>=0)) 472- { mb->filelen=len; 473- if(lseek(mb->fd,mb->filelen-1,SEEK_SET)<0||1!=rwrite(mb->fd,empty,1)) 474+ { mb->filelen=len+1; 475+ if(lseek(mb->fd,len,SEEK_SET)<0||1!=rwrite(mb->fd,empty,1)) 476 dropf: { close(mb->fd);mb->fd= -1; 477 if(verbose)nlog("Unable to extend or use tempfile"); 478 } 479@@ -98,9 +98,9 @@ dropf: { close(mb->fd);mb->fd= -1; 480 } 481 } 482 if(mb->fd>=0) 483- { if(len>mb->filelen) /* need to extend? */ 484- { mb->filelen=len; 485- if(lseek(mb->fd,mb->filelen-1,SEEK_SET)<0||1!=rwrite(mb->fd,empty,1)) 486+ { if(len>=mb->filelen) /* need to extend? */ 487+ { mb->filelen=len+1; 488+ if(lseek(mb->fd,len,SEEK_SET)<0||1!=rwrite(mb->fd,empty,1)) 489 { char*p=malloc(len+1); /* can't extend, switch to malloc */ 490 tmemmove(p,mb->p,mb->len); 491 munmap(mb->p,mb->len+1); 492@@ -124,9 +124,9 @@ mmap: if((mb->p=mmap(0,len+1,P_RW,MAP_SHARED,mb->fd,(off_t)0))==MAP_FAILED) 493 } 494 else 495 mb->p=realloc(mb->p,len+1); 496- mb->len=len+1; 497- mb->p[len]='\0'; 498+ mb->len=len; 499 ret1: 500+ mb->p[len]='\0'; 501 return 1; 502 } 503 504diff --git a/src/memblk.h b/src/memblk.h 505index 6fd1d1d..b57f369 100644 506--- a/src/memblk.h 507+++ b/src/memblk.h 508@@ -1,6 +1,6 @@ 509 typedef struct memblk { 510 char*p; /* where it starts */ 511- long len; /* currently allocated size */ 512+ long len; /* current size, not including trailing NUL */ 513 #ifdef USE_MMAP 514 off_t filelen; /* how long is the file */ 515 int fd; /* file which is mmap()ed */ 516diff --git a/src/network.h b/src/network.h 517index d7d08f2..b09b6c4 100644 518--- a/src/network.h 519+++ b/src/network.h 520@@ -1,19 +1,13 @@ 521 /*$Id: network.h,v 1.7 1997/04/02 03:15:41 srb Exp $*/ 522 523-#include <sys/socket.h> /* socket() sendto() AF_INET 524+#include <sys/socket.h> /* socket() sendto() */ 525 /* SOCK_DGRAM */ 526-#include <netdb.h> /* gethostbyname() getservbyname() 527- /* getprotobyname() */ 528-#include <netinet/in.h> /* htons() struct sockaddr_in */ 529+#include <netdb.h> /* getaddrinfo() */ 530 531 #ifndef BIFF_serviceport 532 #define BIFF_serviceport COMSATservice 533 #endif 534 535-#ifndef h_0addr_list 536-#define h_0addr_list h_addr_list[0] /* POSIX struct member */ 537-#endif 538- 539 #ifndef NO_const /* since network.h is outside the autoconf const check */ 540 #ifdef const /* loop, we need this backcheck for some systems */ 541 #undef const 542diff --git a/src/pipes.c b/src/pipes.c 543index 1fdb9e6..7754300 100644 544--- a/src/pipes.c 545+++ b/src/pipes.c 546@@ -145,7 +145,9 @@ int pipthrough(line,source,len)char*line,*source;const long len; 547 if(Stdout) 548 { *(eq=strchr(Stdout,'\0')-1)='\0'; /* chop the '=' */ 549 if(!(backblock=getenv(Stdout))) /* no current value? */ 550- PRDB=PWRB= -1; 551+ { PRDB=PWRB= -1; 552+ backlen=0; 553+ } 554 else 555 { backlen=strlen(backblock); 556 goto pip; 557@@ -155,9 +157,7 @@ int pipthrough(line,source,len)char*line,*source;const long len; 558 pip: rpipe(pbackfd); 559 rpipe(pinfd); /* main pipes setup */ 560 if(!(pidchild=sfork())) /* create a sending procmail */ 561- { if(Stdout&&backblock) 562- backlen=strlen(backblock); 563- else 564+ { if(!Stdout) 565 backblock=source,backlen=len; 566 childsetup();rclose(PRDI);rclose(PRDB); 567 rpipe(poutfd);rclose(STDOUT); 568@@ -194,7 +194,7 @@ perr: progerr(line,excode,pwait==4); /* I'm going to tell my mommy! */ 569 makeblock(&temp,Stdfilled); 570 tmemmove(temp.p,Stdout,Stdfilled); 571 readdyn(&temp,&Stdfilled,Stdfilled+backlen+1); 572- Stdout=realloc(Stdout,&Stdfilled+1); 573+ Stdout=realloc(Stdout,Stdfilled+1); 574 tmemmove(Stdout,temp.p,Stdfilled+1); 575 freeblock(&temp); 576 retStdout(Stdout,pwait&&pipw,!backblock); 577diff --git a/src/procmail.c b/src/procmail.c 578index 4a232f2..2bb449b 100644 579--- a/src/procmail.c 580+++ b/src/procmail.c 581@@ -652,8 +652,7 @@ commint:do skipspace(); /* skip whitespace */ 582 nrcond= -1; 583 if(tolock) /* clear temporary buffer for lockfile name */ 584 free(tolock); 585- for(i=maxindex(flags);i;i--) /* clear the flags */ 586- flags[i]=0; 587+ bbzero(flags,sizeof(flags)); /* clear the flags */ 588 for(tolock=0,locknext=0;;) 589 { chp=skpspace(chp); 590 switch(i= *chp++) 591diff --git a/src/recommend.c b/src/recommend.c 592index 5d41e01..9002268 100644 593--- a/src/recommend.c 594+++ b/src/recommend.c 595@@ -47,7 +47,7 @@ int main(argc,argv)const int argc;const char*const argv[]; 596 printf("chmod %lo %s\n",(unsigned long)(sgid|PERMIS),argv[2]); 597 else if(chmdir==1) 598 goto nogchmod; 599- if(chmdir) 600+ if(0) 601 printf("chmod %c+w %s/.\n",chmdir==1?'g':'a',mailspooldir); 602 nogchmod: 603 return EXIT_SUCCESS; 604-- 6051.8.4.2 606 607