aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-support/procmail/procmail/from-debian-to-fix-compile-errors.patch
blob: 8341a8ecde8b983ec886dea0dda5fb626f21ba2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
From 898e9514bc889b4a540f667efed95a5af101c824 Mon Sep 17 00:00:00 2001
From: Li xin <lixin.fnst@cn.fujitsu.com>
Date: Tue, 2 Dec 2014 07:00:36 +0900
Subject: [PATCH 1/3] From debian to fix compile errors

Signed-off-by: Li Xin <lixin.fnst@cn.fujitsu.com>
---
 src/Makefile.0  |  7 +++----
 src/autoconf    | 64 +++++++++++++-------------------------------------------
 src/comsat.c    | 65 +++++++++++++++++++--------------------------------------
 src/fields.c    |  6 +++---
 src/foldinfo.h  |  2 +-
 src/formail.c   |  6 +++---
 src/formisc.c   |  2 +-
 src/formisc.h   |  2 +-
 src/mailfold.c  | 14 ++++++++++---
 src/manconf.c   |  2 +-
 src/memblk.c    | 24 ++++++++++-----------
 src/memblk.h    |  2 +-
 src/network.h   | 10 ++-------
 src/pipes.c     | 10 ++++-----
 src/procmail.c  |  3 +--
 src/recommend.c |  2 +-
 16 files changed, 81 insertions(+), 140 deletions(-)

diff --git a/src/Makefile.0 b/src/Makefile.0
index 6eb5b51..15a2039 100644
--- a/src/Makefile.0
+++ b/src/Makefile.0
@@ -40,7 +40,7 @@ multigram: multigram.$(O) $(MG_OBJ) setid
 	@cd ..; $(MAKE) config.check
 
 _autotst: _autotst.$(O) sublib.c sublib.h
-	$(CC) $(CFLAGS) $@.$(O) -o $@ $(LDFLAGS)
+	gcc $@.$(O) -o $@ $(LDFLAGS)
 
 ../autoconf.h: autoconf Makefile ../patchlevel.h
 	@echo No this was not make -n >make_n
@@ -175,17 +175,16 @@ recommend: recommend.$(O) sublib.$(O)
 
 ../man/man.sed: manconf.c ../autoconf.h ../config.h includes.h procmail.h
 ../man/man.sed: ../patchlevel.h
-	@$(CC) $(CFLAGS) "-DBINDIR=\"$(VISIBLE_BINDIR)\"" -o _autotst \
+	gcc "-DBINDIR=\"$(VISIBLE_BINDIR)\"" -o _autotst \
  manconf.c $(LDFLAGS)
 	@./_autotst $@
 	@echo Housekeeping file >$@
-	@$(RM) _autotst
 
 clean:
 	$(RM) -r _locktest
 	$(RM) procmail.$(O) $(PM_OBJ) lockfile.$(O) $(LF_OBJ) formail.$O \
  $(FM_OBJ) multigram.$(O) $(MG_OBJ) $(BINSS) multigram ../autoconf.h \
- _autotst* lookfor _locktst* grepfor recommend recommend.$(O) manconf \
+  lookfor _locktst* grepfor recommend recommend.$(O) manconf \
  _Makefile lock.log *core* targetdir.h setid setid.$(O) gethome \
  gethome.$(O) make_n realloc.log
 
diff --git a/src/autoconf b/src/autoconf
index 1cb4c42..ff78048 100755
--- a/src/autoconf
+++ b/src/autoconf
@@ -68,8 +68,6 @@
 #	#define NOfsync
 #Ok	#define endpwent()
 #Ok	#define endgrent()
-#Ok	#define endhostent()
-#Ok	#define endservent()
 #Ok	#define endprotoent()
 #	#define h_0addr_list h_addr
 #Ok	#define NOpw_passwd
@@ -896,7 +894,7 @@ int main(){int i=0;
  {uid_t vuid_t;i+=vuid_t=1;}
  {gid_t vgid_t;i+=vgid_t=1;}
 #ifndef NO_COMSAT
- {struct hostent vhostent;i+=!(vhostent.h_addr_list=0);}
+ {struct addrinfo res; i+=!(res.ai_socktype=0);}
 #endif
 #ifndef NOuname
  {struct utsname vutsname;i+=!(*vutsname.nodename='\0');}
@@ -917,8 +915,6 @@ do
   test -z "$i3" && grepfor mode_t 'typedef int mode_t;' && i3=I
   test -z "$i4" && grepfor uid_t 'typedef int uid_t;' && i4=I
   test -z "$i5" && grepfor gid_t 'typedef int gid_t;' && i5=I
-  test -z "$i6" && grepfor h_addr_list '#define h_0addr_list h_addr' && i6=I
-  test -z "$i6" && grepfor hostent '#define h_0addr_list h_addr' && i6=I
   test -z "$i6" && grepfor member '#define h_0addr_list h_addr' && i6=I
   test -z "$i7" && grepfor utsname "#define NOuname			      \
 /* <sys/utsname.h> is there, but empty */" && i7=I
@@ -1048,8 +1044,12 @@ int main(){char a[2];
  {struct utsname b;uname(&b);}
 #endif
 #ifndef NO_COMSAT
- gethostbyname("0");getprotobyname(COMSATprotocol);endhostent();endservent();
- endprotoent();
+ {
+ struct addrinfo *res, hints;
+ memset(&hints, '\0', sizeof(hints));
+ if(getaddrinfo(COMSAThost,BIFF_serviceport,&hints,&res))
+ 	freeaddrinfo(res);
+ }
 #endif
  _exit(0);
  return 0;}
@@ -1103,14 +1103,9 @@ grepfor uname "\
 /* <sys/utsname.h> defines it, the libraries don't */"
 grepfor endpwent '#define endpwent()'
 grepfor endgrent '#define endgrent()'
-if grepfor gethostbyname '#define NO_COMSAT'
+if grepfor getaddrinfo '#define NO_COMSAT'
 then
 :
-else
-  grepfor getprotobyname '#define UDP_protocolno 17'
-  grepfor endhostent '#define endhostent()'
-  grepfor endservent '#define endservent()'
-  grepfor endprotoent '#define endprotoent()'
 fi
 grepfor strstr '#define SLOWstrstr' ||
  grepfor clock '#define SLOWstrstr'
@@ -1239,39 +1234,9 @@ int main(argc,argv)int argc;const char*argv[];
 	printf("/* Insufficient memory to perform the benchmark! */\n");
 #endif /* SLOWstrstr */
 #ifndef NO_COMSAT
-#ifndef UDP_protocolno
-     ;{ const struct protoent*p;
-	if(p=getprotobyname(COMSATprotocol))
-	 { printf("#define UDP_protocolno %d\n",p->p_proto);
-#else
-     ;{ if(1)
-	 {
-#endif
-	   ;{ const struct servent*serv;
-	      if(serv=getservbyname(COMSATservice,COMSATprotocol))
-		 printf("#define BIFF_serviceport \"%d\"\n",
-		  ntohs(serv->s_port));
-	    }
-#ifdef AF_INET
-	   ;{ const struct hostent*host;
-	      if(!strcmp("localhost",COMSAThost)&&
-	       (host=gethostbyname(COMSAThost))&&
-	       host->h_0addr_list&&host->h_addrtype==AF_INET&&
-	       host->h_length)
-	       { int j=host->h_length;
-		 const unsigned char*ad=(void*)host->h_0addr_list;
-		 printf("#define IP_localhost {");
-		 printf("%d",*ad++);
-		 while(--j)
-		    printf(",%d",*ad++);
-		 puts("}");
-	       }
-	    }
+#ifndef AF_INET
+	puts("#define NO_COMSAT");
 #endif /* AF_INET */
-	 }
-	else
-	   puts("#define NO_COMSAT");
-      }
 #endif /* NO_COMSAT */
      ;{ unsigned long s=(size_t)~0;int bits;
 	for(bits=1;s>>=1;bits++);
@@ -1470,15 +1435,14 @@ cat /usr/lib/sendmail.cf /etc/sendmail.cf /etc/mail/sendmail.cf 2>$DEVNULL |
  grep 'Mlocal.*procmail' >$DEVNULL ||
  echo '#define CF_no_procmail_yet' >>$ACONF
 
-cat /usr/lib/sendmail.cf /etc/sendmail.cf /etc/mail/sendmail.cf 2>$DEVNULL |
- grep '^V' >$DEVNULL ||
- echo '#define buggy_SENDMAIL' >>$ACONF
+# cat /usr/lib/sendmail.cf /etc/sendmail.cf /etc/mail/sendmail.cf 2>$DEVNULL |
+#  grep '^V' >$DEVNULL ||
+#  echo '#define buggy_SENDMAIL' >>$ACONF
 
 lpath='/bin'
 bins="/bin"
 
-for newd in /usr/bin /usr/ucb /usr/5bin $BINDIR /local/bin /usr/local/bin \
- /global/bin /usr/bin/X11 /usr/X*/bin
+for newd in /usr/bin $BINDIR /usr/bin/X11 /usr/X*/bin
 do
   if test -d $newd
   then
diff --git a/src/comsat.c b/src/comsat.c
index 77dba34..5082b16 100644
--- a/src/comsat.c
+++ b/src/comsat.c
@@ -27,7 +27,8 @@ static /*const*/char rcsid[]=
 #include "comsat.h"
 
 static int csvalid;		     /* is it turned on with a good address? */
-static struct sockaddr_in csaddr;
+static struct addrinfo cai;
+static struct sockaddr *csaddr;
 static char*cslastf,*cslgname;
 
 void setlfcs(folder)const char*folder;		/* set lastfolder for comsat */
@@ -62,56 +63,32 @@ void setlgcs(name)const char*name;		   /* set logname for comsat */
 }
 
 int setcomsat(chp)const char*chp;
-{ char*chad;int newvalid; struct sockaddr_in newaddr;
+{ char*chad;int newvalid; struct addrinfo *res, hints;
   chad=strchr(chp,SERV_ADDRsep);			     /* @ separator? */
   if(!chad&&!renvint(-1L,chp))
      return csvalid=0;					/* turned off comsat */
   newvalid=1;
   if(chad)
      *chad++='\0';				      /* split the specifier */
+  if(!chad||!*chp)					       /* no service */
+     chp=BIFF_serviceport;				/* new balls please! */
   if(!chad||!*chad)						  /* no host */
-#ifndef IP_localhost			      /* Is "localhost" preresolved? */
      chad=COMSAThost;					/* nope, use default */
-#else /* IP_localhost */
-   { static const unsigned char ip_localhost[]=IP_localhost;
-     newaddr.sin_family=AF_INET;
-     tmemmove(&newaddr.sin_addr,ip_localhost,sizeof ip_localhost);
-   }
-  else
-#endif /* IP_localhost */
-   { const struct hostent*host;		      /* what host?  paranoid checks */
-     if(!(host=gethostbyname(chad))||!host->h_0addr_list)
-      { bbzero(&newaddr.sin_addr,sizeof newaddr.sin_addr);
-	newvalid=0;			     /* host can't be found, too bad */
-      }
-     else
-      { newaddr.sin_family=host->h_addrtype;	     /* address number found */
-	tmemmove(&newaddr.sin_addr,host->h_0addr_list,host->h_length);
-      }
-     endhostent();
-   }
-  if(newvalid)						  /* so far, so good */
-   { int s;
-     if(!*chp)						       /* no service */
-	chp=BIFF_serviceport;				/* new balls please! */
-     s=strtol(chp,&chad,10);
-     if(chp!=chad)			       /* the service is not numeric */
-	newaddr.sin_port=htons((short)s);		    /* network order */
-     else
-      { const struct servent*serv;
-	serv=getservbyname(chp,COMSATprotocol);		   /* so get its no. */
-	if(serv)
-	   newaddr.sin_port=serv->s_port;
-	else
-	 { newaddr.sin_port=htons((short)0);		  /* no such service */
-	   newvalid=0;
-	 }
-	endservent();
-      }
-   }
+  bzero(&hints,sizeof(hints));
+  hints.ai_socktype=SOCK_DGRAM;
+  hints.ai_flags=AI_ADDRCONFIG;
+  if(getaddrinfo(chad,chp,&hints,&res))
+     newvalid=0;
+  
   onguard();				    /* update the address atomically */
   if(csvalid=newvalid)
-     tmemmove(&csaddr,&newaddr,sizeof(newaddr));
+   { if(csaddr)
+        free(csaddr);
+     csaddr=malloc(res->ai_addrlen);
+     tmemmove(csaddr,res->ai_addr,res->ai_addrlen);
+     tmemmove(&cai,res,sizeof(cai));
+     freeaddrinfo(res);
+   }
   offguard();
   return newvalid;
 }
@@ -120,7 +97,7 @@ void sendcomsat(folder)const char*folder;
 { int s;const char*p;
   if(!csvalid||!buf)		  /* is comat on and set to a valid address? */
      return;
-  if(!*cslgname||strlen(cslgname)+2>linebuf)	       /* is $LOGNAME bogus? */
+  if(!cslgname||!*cslgname||strlen(cslgname)+2>linebuf)/* is $LOGNAME bogus? */
      return;
   if(!(p=folder?folder:cslastf))		     /* do we have a folder? */
      return;
@@ -132,8 +109,8 @@ void sendcomsat(folder)const char*folder;
    }
   strlcat(buf,COMSATxtrsep,linebuf);			 /* custom seperator */
   strlcat(buf,p,linebuf);			  /* where was it delivered? */
-  if((s=socket(AF_INET,SOCK_DGRAM,UDP_protocolno))>=0)
-   { sendto(s,buf,strlen(buf),0,(struct sockaddr*)&csaddr,sizeof(csaddr));
+  if((s=socket(cai.ai_family,cai.ai_socktype,cai.ai_protocol))>=0)
+   { sendto(s,buf,strlen(buf),0,csaddr,cai.ai_addrlen);
      rclose(s);
      yell("Notified comsat:",buf);
    }
diff --git a/src/fields.c b/src/fields.c
index a2bd77f..37ed154 100644
--- a/src/fields.c
+++ b/src/fields.c
@@ -110,16 +110,16 @@ void dispfield(p)register const struct field*p;
 		    /* try and append one valid field to rdheader from stdin */
 int readhead P((void))
 { int idlen;
-  getline();
+  get_line();
   if((idlen=breakfield(buf,buffilled))<=0) /* not the start of a valid field */
      return 0;
   if(idlen==STRLEN(FROM)&&eqFrom_(buf))			/* it's a From_ line */
    { if(rdheader)
 	return 0;			       /* the From_ line was a fake! */
-     for(;buflast=='>';getline());	    /* gather continued >From_ lines */
+     for(;buflast=='>';get_line());	    /* gather continued >From_ lines */
    }
   else
-     for(;;getline())		      /* get the rest of the continued field */
+     for(;;get_line())		      /* get the rest of the continued field */
       { switch(buflast)			     /* will this line be continued? */
 	 { case ' ':case '\t':				  /* yep, it sure is */
 	      continue;
diff --git a/src/foldinfo.h b/src/foldinfo.h
index 9e4ebb6..797f9be 100644
--- a/src/foldinfo.h
+++ b/src/foldinfo.h
@@ -10,7 +10,7 @@
 
 #define ft_lock(type)	   ((type)>ft_MAILDIR)		   /* kernel lock fd */
 #define ft_atime(type)	   ((type)==ft_FILE)	      /* force atime < mtime */
-#define ft_dotlock(type)   ((type)==ft_FILE)		 /* dotlock $DEFAULT */
+#define ft_dotlock(type)   ((type)>ft_MAILDIR)		 /* dotlock $DEFAULT */
 #define ft_delim(type)	   ((type)==ft_FILE)		   /* add MMDF delim */
 #define ft_checkcloser(type) ((type)>ft_MH)
 #define ft_forceblank(type) ((type)!=ft_MAILDIR)  /* force blank line at end */
diff --git a/src/formail.c b/src/formail.c
index fe5e6be..1f5c9dd 100644
--- a/src/formail.c
+++ b/src/formail.c
@@ -758,9 +758,9 @@ startover:
 	lputssn(buf,buffilled),ctlength-=buffilled,buffilled=lnl=0;
      ;{ int tbl=buflast,lwr='\n';
 	while(--ctlength>=0&&tbl!=EOF)	       /* skip Content-Length: bytes */
-	   lnl=lwr==tbl&&lwr=='\n',putcs(lwr=tbl),tbl=getchar();
+	   lnl=lwr==tbl&&lwr=='\n',lputcs(lwr=tbl),tbl=getchar();
 	if((buflast=tbl)=='\n'&&lwr!=tbl)	/* just before a line break? */
-	   putcs('\n'),buflast=getchar();		/* wrap up loose end */
+	   lputcs('\n'),buflast=getchar();		/* wrap up loose end */
       }
      if(!quiet&&ctlength>0)
       { charNUM(num,ctlength);
@@ -819,7 +819,7 @@ splitit:       { if(!lnl)   /* did the previous mail end with an empty line? */
       { if(split)		       /* gobble up the next start separator */
 	 { buffilled=0;
 #ifdef sMAILBOX_SEPARATOR
-	   getline();buffilled=0;		 /* but only if it's defined */
+	   get_line();buffilled=0;		 /* but only if it's defined */
 #endif
 	   if(buflast!=EOF)					   /* if any */
 	      goto splitit;
diff --git a/src/formisc.c b/src/formisc.c
index d6cab90..338733b 100644
--- a/src/formisc.c
+++ b/src/formisc.c
@@ -115,7 +115,7 @@ void loadchar(c)const int c;		      /* append one character to buf */
   buf[buffilled++]=c;
 }
 
-int getline P((void))			   /* read a newline-terminated line */
+int get_line P((void))			   /* read a newline-terminated line */
 { if(buflast==EOF)			 /* at the end of our Latin already? */
    { loadchar('\n');					  /* fake empty line */
      return EOF;					  /* spread the word */
diff --git a/src/formisc.h b/src/formisc.h
index 1c4ca20..f25211c 100644
--- a/src/formisc.h
+++ b/src/formisc.h
@@ -17,4 +17,4 @@ void
 char*
  skipwords P((char*start));
 int
- getline P((void));
+ get_line P((void));
diff --git a/src/mailfold.c b/src/mailfold.c
index 917b502..6c8bcf4 100644
--- a/src/mailfold.c
+++ b/src/mailfold.c
@@ -30,6 +30,7 @@ static /*const*/char rcsid[]=
 
 int logopened,rawnonl;
 off_t lasttell;
+static int trunced;
 static long lastdump;
 static volatile int mailread;	/* if the mail is completely read in already */
 static struct dyna_array confield;		  /* escapes, concatenations */
@@ -81,6 +82,7 @@ long dump(s,type,source,len)const int s,type;const char*source;
  long len;
 { int i;long part;
   lasttell=i= -1;SETerrno(EBADF);
+  trunced=0;
   if(s>=0)
    { if(ft_lock(type)&&(lseek(s,(off_t)0,SEEK_END),fdlock(s)))
 	nlog("Kernel-lock failed\n");
@@ -120,13 +122,18 @@ jin:	while(part&&(i=rwrite(s,source,BLKSIZ<part?BLKSIZ:(int)part)))
       }
 writefin:
      i=type!=ft_PIPE&&fsync(s)&&errno!=EINVAL;	  /* EINVAL => wasn't a file */
+     if ((i||len)&&lasttell>=0)
+      { int serrno=errno;
+	if(!ftruncate(s,lasttell)) trunced=1;
+	SETerrno(serrno);
+      }
      if(ft_lock(type))
       { int serrno=errno;		       /* save any error information */
 	if(fdunlock())
 	   nlog("Kernel-unlock failed\n");
 	SETerrno(serrno);
       }
-     i=rclose(s)||i;
+     i=rclose(s)||i; /* if this fails, we should truncate, but it's too late */
    }			   /* return an error even if nothing was to be sent */
   return i&&!len?-1:len;
 }
@@ -237,7 +244,7 @@ dumpf:	 { switch(errno)
 #endif
 	      default:writeerr(buf);
 	    }
-	   if(lasttell>=0&&!truncate(boxname,lasttell)&&(logopened||verbose))
+	   if(lasttell>=0&&trunced&&(logopened||verbose))
 	      nlog("Truncated file to former size\n");	    /* undo garbage */
 ret0:	   return 0;
 	 }
@@ -378,7 +385,8 @@ void readmail(rhead,tobesent)const long tobesent;
 	dfilled=mailread=0;
      else if(rhead)				/* only read in a new header */
       { memblk new;
-	dfilled=mailread=0;makeblock(&new,0);readdyn(&new,&dfilled,0);
+	dfilled=mailread=0;makeblock(&new,0);
+	readdyn(&new,&dfilled,thebody-themail.p);
 	if(tobesent>dfilled&&isprivate)		     /* put it in place here */
 	 { tmemmove(themail.p+dfilled,thebody,filled-=tobesent);
 	   tmemmove(themail.p,new.p,dfilled);
diff --git a/src/manconf.c b/src/manconf.c
index a9e9f1c..5c8ec36 100644
--- a/src/manconf.c
+++ b/src/manconf.c
@@ -233,7 +233,7 @@ a security violation was found (e.g. \1.B \2-@PRESERVOPT@\1or variable\
  \2-@PRESERVOPT@\1and\1.BR \2-@FROMWHOPT@ .\1");
   pc("LMTPOPT",LMTPOPT);
 #else
-  ps("LMTPOPTdesc","");ps("LMTPusage","");
+  ps("LMTPOPTdesc","");ps("LMTPusage","\1");
 #endif
   pname("INIT_UMASK",0);printf("0%lo/g\n",(unsigned long)INIT_UMASK);lines--;
   pn("DEFlinebuf",DEFlinebuf);
diff --git a/src/memblk.c b/src/memblk.c
index e2f13f0..97e02d3 100644
--- a/src/memblk.c
+++ b/src/memblk.c
@@ -51,11 +51,11 @@ void lockblock(mb)memblk*const mb;
 {
 #ifdef USE_MMAP
   if(mb->fd>=0)
-   { long len=mb->len+1;
-     if(munmap(mb->p,len))
-	mmapfailed(len);		      /* don't want to continue here */
-     if((mb->p=mmap(0,len,PROT_READ,MAP_PRIVATE,mb->fd,(off_t)0))==MAP_FAILED)
-	mmapfailed(len);
+   { long mlen=mb->len+1;
+     if(munmap(mb->p,mlen))
+	mmapfailed(mlen);		      /* don't want to continue here */
+     if((mb->p=mmap(0,mlen,PROT_READ,MAP_PRIVATE,mb->fd,(off_t)0))==MAP_FAILED)
+	mmapfailed(mlen);
      close(mb->fd);
      mb->fd=ropen(devnull,O_RDWR,0);		/* XXX Perhaps -1 is better? */
    }
@@ -77,8 +77,8 @@ int resizeblock(mb,len,nonfatal)memblk*const mb;const long len;
      strcpy(filename,MMAP_DIR);
      if(unique(filename,strchr(filename,'\0'),MMAP_FILE_LEN,MMAP_PERM,0,0)&&
 	(mb->fd=ropen(filename,O_RDWR,MMAP_PERM),unlink(filename),mb->fd>=0))
-      { mb->filelen=len;
-	if(lseek(mb->fd,mb->filelen-1,SEEK_SET)<0||1!=rwrite(mb->fd,empty,1))
+      { mb->filelen=len+1;
+	if(lseek(mb->fd,len,SEEK_SET)<0||1!=rwrite(mb->fd,empty,1))
 dropf:	 { close(mb->fd);mb->fd= -1;
 	   if(verbose)nlog("Unable to extend or use tempfile");
 	 }
@@ -98,9 +98,9 @@ dropf:	 { close(mb->fd);mb->fd= -1;
       }
    }
   if(mb->fd>=0)
-   { if(len>mb->filelen)				  /* need to extend? */
-      { mb->filelen=len;
-	if(lseek(mb->fd,mb->filelen-1,SEEK_SET)<0||1!=rwrite(mb->fd,empty,1))
+   { if(len>=mb->filelen)				  /* need to extend? */
+      { mb->filelen=len+1;
+	if(lseek(mb->fd,len,SEEK_SET)<0||1!=rwrite(mb->fd,empty,1))
 	 { char*p=malloc(len+1);	   /* can't extend, switch to malloc */
 	   tmemmove(p,mb->p,mb->len);
 	   munmap(mb->p,mb->len+1);
@@ -124,9 +124,9 @@ mmap:	if((mb->p=mmap(0,len+1,P_RW,MAP_SHARED,mb->fd,(off_t)0))==MAP_FAILED)
    }
   else
      mb->p=realloc(mb->p,len+1);
-  mb->len=len+1;
-  mb->p[len]='\0';
+  mb->len=len;
 ret1:
+  mb->p[len]='\0';
   return 1;
 }
 
diff --git a/src/memblk.h b/src/memblk.h
index 6fd1d1d..b57f369 100644
--- a/src/memblk.h
+++ b/src/memblk.h
@@ -1,6 +1,6 @@
 typedef struct memblk {
     char*p;						  /* where it starts */
-    long len;					 /* currently allocated size */
+    long len;			 /* current size, not including trailing NUL */
 #ifdef USE_MMAP
     off_t filelen;				     /* how long is the file */
     int fd;					   /* file which is mmap()ed */
diff --git a/src/network.h b/src/network.h
index d7d08f2..b09b6c4 100644
--- a/src/network.h
+++ b/src/network.h
@@ -1,19 +1,13 @@
 /*$Id: network.h,v 1.7 1997/04/02 03:15:41 srb Exp $*/
 
-#include <sys/socket.h>			/* socket() sendto() AF_INET
+#include <sys/socket.h>			/* socket() sendto() */
 					/* SOCK_DGRAM */
-#include <netdb.h>			/* gethostbyname() getservbyname()
-					/* getprotobyname() */
-#include <netinet/in.h>			/* htons() struct sockaddr_in */
+#include <netdb.h>			/* getaddrinfo() */
 
 #ifndef BIFF_serviceport
 #define BIFF_serviceport	COMSATservice
 #endif
 
-#ifndef h_0addr_list
-#define h_0addr_list	h_addr_list[0]		      /* POSIX struct member */
-#endif
-
 #ifndef NO_const      /* since network.h is outside the autoconf const check */
 #ifdef const		    /* loop, we need this backcheck for some systems */
 #undef const
diff --git a/src/pipes.c b/src/pipes.c
index 1fdb9e6..7754300 100644
--- a/src/pipes.c
+++ b/src/pipes.c
@@ -145,7 +145,9 @@ int pipthrough(line,source,len)char*line,*source;const long len;
   if(Stdout)
    { *(eq=strchr(Stdout,'\0')-1)='\0';			     /* chop the '=' */
      if(!(backblock=getenv(Stdout)))			/* no current value? */
-	PRDB=PWRB= -1;
+      { PRDB=PWRB= -1;
+	backlen=0;
+      }
      else
       { backlen=strlen(backblock);
 	goto pip;
@@ -155,9 +157,7 @@ int pipthrough(line,source,len)char*line,*source;const long len;
 pip: rpipe(pbackfd);
   rpipe(pinfd);						 /* main pipes setup */
   if(!(pidchild=sfork()))			/* create a sending procmail */
-   { if(Stdout&&backblock)
-	backlen=strlen(backblock);
-     else
+   { if(!Stdout)
 	backblock=source,backlen=len;
      childsetup();rclose(PRDI);rclose(PRDB);
      rpipe(poutfd);rclose(STDOUT);
@@ -194,7 +194,7 @@ perr:	      progerr(line,excode,pwait==4);  /* I'm going to tell my mommy! */
      makeblock(&temp,Stdfilled);
      tmemmove(temp.p,Stdout,Stdfilled);
      readdyn(&temp,&Stdfilled,Stdfilled+backlen+1);
-     Stdout=realloc(Stdout,&Stdfilled+1);
+     Stdout=realloc(Stdout,Stdfilled+1);
      tmemmove(Stdout,temp.p,Stdfilled+1);
      freeblock(&temp);
      retStdout(Stdout,pwait&&pipw,!backblock);
diff --git a/src/procmail.c b/src/procmail.c
index 4a232f2..2bb449b 100644
--- a/src/procmail.c
+++ b/src/procmail.c
@@ -652,8 +652,7 @@ commint:do skipspace();					  /* skip whitespace */
 	      nrcond= -1;
 	   if(tolock)		 /* clear temporary buffer for lockfile name */
 	      free(tolock);
-	   for(i=maxindex(flags);i;i--)			  /* clear the flags */
-	      flags[i]=0;
+	   bbzero(flags,sizeof(flags));		  /* clear the flags */
 	   for(tolock=0,locknext=0;;)
 	    { chp=skpspace(chp);
 	      switch(i= *chp++)
diff --git a/src/recommend.c b/src/recommend.c
index 5d41e01..9002268 100644
--- a/src/recommend.c
+++ b/src/recommend.c
@@ -47,7 +47,7 @@ int main(argc,argv)const int argc;const char*const argv[];
      printf("chmod %lo %s\n",(unsigned long)(sgid|PERMIS),argv[2]);
   else if(chmdir==1)
      goto nogchmod;
-  if(chmdir)
+  if(0)
      printf("chmod %c+w %s/.\n",chmdir==1?'g':'a',mailspooldir);
 nogchmod:
   return EXIT_SUCCESS;
-- 
1.8.4.2