]> arthur.barton.de Git - homebrew-alex.git/blob - sendfile.rb
New formula: sendfile 2.1b
[homebrew-alex.git] / sendfile.rb
1 require 'formula'
2
3 class Sendfile < Formula
4   homepage ''
5   url 'http://fex.rus.uni-stuttgart.de/download/sendfile-2.1b.tar.gz'
6   md5 '0397cbbf6261b27a1ddcbbd11ff7335c'
7
8   def patches
9     # source code:
10     #  - remove nested "MAXS() inside snprintf()" macros.
11     #  - disable wtmp/utmp on Mac OS X.
12     #  - only call seteuid() & setegid() when it would change user/group.
13     DATA
14   end
15
16   def install
17     inreplace ["makeconfig", "etc/sfdconf", "doc/receive.1", "doc/sendfile.1", "doc/sendmsg.1", "doc/sendfiled.8" ] do |s|
18       s.gsub! "/usr/local", "#{HOMEBREW_PREFIX}"
19       s.gsub! "/var/spool/sendfile", (var + 'spool/sendfile')
20     end
21
22     system "make config"
23     system "make all"
24
25     sbin.install 'src/sendfiled'
26     sbin.install 'etc/sfdconf'
27     bin.install 'src/fetchfile', 'src/receive', 'src/sendfile', 'src/sendmsg'
28     bin.install 'src/utf7encode', 'src/wlock'
29     bin.install 'etc/check_sendfile', 'etc/sfconf'
30     etc.install 'etc/sendfile.cf', 'etc/sendfile.deny'
31     man1.install 'doc/fetchfile.1', 'doc/receive.1', 'doc/sendfile.1', 'doc/sendmsg.1'
32     man1.install 'doc/utf7encode.1', 'doc/wlock.1'
33     man8.install 'doc/sendfiled.8'
34
35     (var + 'spool/sendfile/LOG').mkpath
36     (var + 'spool/sendfile/OUTGOING').mkpath
37     (var + 'spool/sendfile/LOG').chmod 00700
38     (var + 'spool/sendfile/OUTGOING').chmod 01777
39
40     plist_path.write startup_plist
41     plist_path.chmod 0644
42   end
43
44   def caveats; <<-EOCAVEATS
45 # Start/Stop sendfiled(8) Daemon
46
47 Note: if you only want to send file using sendfile(1) or messages using
48 sendmsg(1), and don't want to receive any files or messages at all, you
49 don't have to enable the sendfiled(8) server daemon!
50
51 If this is your first install, automatically load on login with:
52   sudo cp #{plist_path} /Library/LaunchDaemons/
53   sudo launchctl load -w /Library/LaunchDaemons/#{plist_path.basename}
54
55 If this is an upgrade and you already have the #{plist_path.basename} loaded:
56   sudo launchctl unload -w /Library/LaunchDaemons/#{plist_path.basename}
57   sudo cp #{plist_path} /Library/LaunchDaemons/
58   sudo launchctl load -w /Library/LaunchDaemons/#{plist_path.basename}
59 EOCAVEATS
60   end
61
62   def startup_plist
63     return <<-EOPLIST
64 <?xml version="1.0" encoding="UTF-8"?>
65 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
66 <plist version="1.0">
67 <dict>
68   <key>Label</key>
69   <string>#{plist_name}</string>
70   <key>ProgramArguments</key>
71   <array>
72     <string>#{HOMEBREW_PREFIX}/sbin/sendfiled</string>
73   </array>
74   <key>UserName</key>
75   <string>root</string>
76   <key>inetdCompatibility</key>
77   <dict>
78     <key>Wait</key>
79     <false/>
80   </dict>
81   <key>Sockets</key>
82   <dict>
83     <key>Listeners</key>
84     <dict>
85       <key>SockServiceName</key>
86       <string>saft</string>
87     </dict>
88   </dict>
89   <key>WorkingDirectory</key>
90   <string>#{HOMEBREW_PREFIX}</string>
91 </dict>
92 </plist>
93     EOPLIST
94   end
95
96 end
97
98 __END__
99
100  src/address.c   |   66 ++++++++--------
101  src/fetchfile.c |  126 ++++++++++++++--------------
102  src/io.c        |   28 +++---
103  src/net.c       |   32 ++++----
104  src/receive.c   |  216 ++++++++++++++++++++++++------------------------
105  src/sendfile.c  |  242 +++++++++++++++++++++++++++---------------------------
106  src/sendfiled.c |  180 +++++++++++++++++++++--------------------
107  src/sendmsg.c   |   20 +++---
108  src/spool.c     |   38 +++++-----
109  9 files changed, 475 insertions(+), 473 deletions(-)
110
111 diff --git a/src/address.c b/src/address.c
112 index 4c75028..dcf6cd1 100644
113 --- a/src/address.c
114 +++ b/src/address.c
115 @@ -134,15 +134,15 @@ void destination(int argc, char **argv,
116    snprintf(user,FLEN-1,"%s %s",pwe->pw_name,gecos);
117    
118    /* check user configuration directory */
119 -  snprintf(MAXS(userconfig),"%s/.sendfile",pwe->pw_dir);
120 -  snprintf(MAXS(tmp),SPOOL"/%s/config",pwe->pw_name);
121 +  snprintf(userconfig,sizeof(userconfig)-1,"%s/.sendfile",pwe->pw_dir);
122 +  snprintf(tmp,sizeof(tmp)-1,SPOOL"/%s/config",pwe->pw_name);
123    if (stat(userconfig,&finfo)<0 && stat(tmp,&finfo)==0)
124      symlink(tmp,userconfig);
125    
126    /* trick: argc == 0, when message reply mode */
127    if (argc==0) {
128      if (gethostname(localhost,FLEN-1)<0) strcpy(localhost,"localhost");
129 -    snprintf(MAXS(tmp),"%s/msg@%s",userconfig,localhost);
130 +    snprintf(tmp,sizeof(tmp)-1,"%s/msg@%s",userconfig,localhost);
131      if ((inf=rfopen(tmp,"r")) && fgetl(line,inf)) {
132        if ((cp=strchr(line,'\n'))) *cp=0;
133        if ((cp=strchr(line,'@'))) {
134 @@ -187,12 +187,12 @@ void destination(int argc, char **argv,
135      strcpy(recipient,larg);
136  
137      /* check the sendfile alias file */
138 -    snprintf(MAXS(aliasfile),"%s/aliases",userconfig);
139 +    snprintf(aliasfile,sizeof(aliasfile)-1,"%s/aliases",userconfig);
140      if (check_alias(aliasfile,recipient,host,aopt)<0) {
141       
142  #ifdef RESPECT_MAIL_ALIASES
143        /* check the elm alias file */
144 -      snprintf(MAXS(aliasfile),"%s/.elm/aliases.text",pwe->pw_dir);
145 +      snprintf(aliasfile,sizeof(aliasfile)-1,"%s/.elm/aliases.text",pwe->pw_dir);
146        if (check_alias(aliasfile,recipient,host,aopt)<0) {
147         
148  #endif
149 @@ -342,7 +342,7 @@ int check_forward(int sockfd, char *recipient, char *host, char *redirect) {
150  
151    /* illegal answer */
152    if (!str_beq(reply,"200 ")) {
153 -    snprintf(MAXS(tmp),"server error: %s",reply+4);
154 +    snprintf(tmp,sizeof(tmp)-1,"server error: %s",reply+4);
155      errno=0;
156      if (client) message(prg,'F',tmp);
157      strcpy(redirect,reply+4);
158 @@ -405,7 +405,7 @@ int saft_connect(const char *type,
159      /* if the finger-port is specified get real port from there */
160      if (port==79 || !port) {
161        if ((cp=strchr(host,':'))) *cp=0;
162 -      snprintf(MAXS(tmp),"opening connection to finger://%s/%s",host,recipient);
163 +      snprintf(tmp,sizeof(tmp)-1,"opening connection to finger://%s/%s",host,recipient);
164        if (quiet<2) message(prg,'I',tmp);
165        port=finger_saft_port(recipient,host);
166        if (port<1) {
167 @@ -417,7 +417,7 @@ int saft_connect(const char *type,
168      }
169        
170      /* initiate the SAFT-connection to the server */
171 -    snprintf(MAXS(tmp),"opening connection to saft://%s/%s",host,recipient);
172 +    snprintf(tmp,sizeof(tmp)-1,"opening connection to saft://%s/%s",host,recipient);
173      if (quiet<2) message(prg,'I',tmp);
174      sockfd=open_connection(host,port);
175  
176 @@ -426,13 +426,13 @@ int saft_connect(const char *type,
177        /* host has no ip-address, but we can try more ... */
178        if (sockfd==-3 && str_eq(type,"file")) {
179         if (client) {
180 -         snprintf(MAXS(tmp),"%s has no internet-address",host);
181 +         snprintf(tmp,sizeof(tmp)-1,"%s has no internet-address",host);
182           if (quiet<2) message(prg,'W',tmp);
183         }
184      
185         /* try generic saft-address for this host/domain */
186         if (port==SAFT) {
187 -         snprintf(MAXS(ahost),"saft.%s",host);
188 +         snprintf(ahost,sizeof(ahost)-1,"saft.%s",host);
189           if (client) {
190             if(gethostbyname(ahost)){
191               if (!quiet) {
192 @@ -446,7 +446,7 @@ int saft_connect(const char *type,
193           if (tolower(*answer)!='n' || !client) {
194             strcpy(host,ahost);
195             if (client) {
196 -             snprintf(MAXS(tmp),"opening connection to %s@%s",recipient,host);
197 +             snprintf(tmp,sizeof(tmp)-1,"opening connection to %s@%s",recipient,host);
198               if (quiet<2) message(prg,'I',tmp);
199             }
200             sockfd=open_connection(host,port);
201 @@ -458,13 +458,13 @@ int saft_connect(const char *type,
202        /* try user SAFT port on connection failure */
203        if (sockfd==-2 && str_eq(type,"file")) {
204         if (verbose) {
205 -         snprintf(MAXS(tmp),"cannot connect to SAFT port %d on %s",
206 +         snprintf(tmp,sizeof(tmp)-1,"cannot connect to SAFT port %d on %s",
207                    port,host);
208           message(prg,'E',tmp);
209         }
210         port=finger_saft_port(recipient,host);
211         if (port>0 && port!=SAFT) {
212 -         snprintf(MAXS(tmp),"%s has no system SAFT server, "
213 +         snprintf(tmp,sizeof(tmp)-1,"%s has no system SAFT server, "
214                    "trying user SAFT server on port %d",host,port);
215           if (quiet<2) message(prg,'W',tmp);
216           sockfd=open_connection(host,port);
217 @@ -474,9 +474,9 @@ int saft_connect(const char *type,
218        
219      }
220      
221 -    if (sockfd==-1) snprintf(MAXS(tmp),"cannot create a network socket");
222 -    if (sockfd==-2) snprintf(MAXS(tmp),"cannot open connection to %s",host);
223 -    if (sockfd==-3) snprintf(MAXS(tmp),"%s is unknown",host);
224 +    if (sockfd==-1) snprintf(tmp,sizeof(tmp)-1,"cannot create a network socket");
225 +    if (sockfd==-2) snprintf(tmp,sizeof(tmp)-1,"cannot open connection to %s",host);
226 +    if (sockfd==-3) snprintf(tmp,sizeof(tmp)-1,"%s is unknown",host);
227      if (sockfd<0) {
228        if (client) {
229         errno=0;
230 @@ -488,7 +488,7 @@ int saft_connect(const char *type,
231      /* no remote server or protocol error? */
232      sock_getline(sockfd,line);
233      if (!str_beq(line,"220 ") || !strstr(line,"SAFT")) {
234 -      snprintf(MAXS(tmp),"No SAFT server on port %d at %s",port,host);
235 +      snprintf(tmp,sizeof(tmp)-1,"No SAFT server on port %d at %s",port,host);
236        if ((cp=strrchr(tmp,':'))) *cp=0;
237        if (client) {
238         errno=0;
239 @@ -500,9 +500,9 @@ int saft_connect(const char *type,
240      }
241  
242      /* send constant header lines */
243 -    snprintf(MAXS(tmp),"FROM %s",user);
244 +    snprintf(tmp,sizeof(tmp)-1,"FROM %s",user);
245      sendheader(sockfd,tmp);
246 -    snprintf(MAXS(tmp),"TO %s",recipient);
247 +    snprintf(tmp,sizeof(tmp)-1,"TO %s",recipient);
248      sock_putline(sockfd,tmp);
249  
250      /* is there a forward set? */
251 @@ -659,7 +659,7 @@ int saft_connect(const char *type,
252        } else {
253          if ((cp=strchr(host,':'))) *cp=0;
254        }
255 -      snprintf(MAXS(tmp),"opening connection to finger://%s/%s",host,recipient);
256 +      snprintf(tmp,sizeof(tmp)-1,"opening connection to finger://%s/%s",host,recipient);
257        if (quiet<2) message(prg,'I',tmp);
258        service=finger_saft_port(recipient,host);
259        if (service==NULL) {
260 @@ -671,7 +671,7 @@ int saft_connect(const char *type,
261      }
262        
263      /* initiate the SAFT-connection to the server */
264 -    snprintf(MAXS(tmp),"opening connection to saft://%s/%s",host,recipient);
265 +    snprintf(tmp,sizeof(tmp)-1,"opening connection to saft://%s/%s",host,recipient);
266      if (quiet<2) message(prg,'I',tmp);
267      sockfd=open_connection(host,service);
268  
269 @@ -680,13 +680,13 @@ int saft_connect(const char *type,
270        /* host has no ip-address, but we can try more ... */
271        if (sockfd==-3 && str_eq(type,"file")) {
272         if (client) {
273 -         snprintf(MAXS(tmp),"%s has no internet-address",host);
274 +         snprintf(tmp,sizeof(tmp)-1,"%s has no internet-address",host);
275           if (quiet<2) message(prg,'W',tmp);
276         }
277      
278         /* try generic saft-address for this host/domain */
279         if (strcasecmp(service, SERVICE) == 0 || strcmp(service, PORT_STRING) == 0) {
280 -         snprintf(MAXS(ahost),"saft.%s",host);
281 +         snprintf(ahost,sizeof(ahost)-1,"saft.%s",host);
282           if (client) {
283             sockfd=open_connection(host,service);
284             if(sockfd >= 0){
285 @@ -701,7 +701,7 @@ int saft_connect(const char *type,
286           if (tolower(*answer)!='n' || !client) {
287             strcpy(host,ahost);
288             if (client) {
289 -             snprintf(MAXS(tmp),"opening connection to %s@%s",recipient,host);
290 +             snprintf(tmp,sizeof(tmp)-1,"opening connection to %s@%s",recipient,host);
291               if (quiet<2) message(prg,'I',tmp);
292             }
293           } else {
294 @@ -715,14 +715,14 @@ int saft_connect(const char *type,
295        /* try user SAFT port on connection failure */
296        if (sockfd==-2 && str_eq(type,"file")) {
297         if (verbose) {
298 -         snprintf(MAXS(tmp),"cannot connect to SAFT port %s on %s",
299 +         snprintf(tmp,sizeof(tmp)-1,"cannot connect to SAFT port %s on %s",
300                    service,host);
301           message(prg,'E',tmp);
302         }
303         service=finger_saft_port(recipient,host);
304          if (service != NULL) needsFree = 1;
305         if (service != NULL && strcasecmp(service, SERVICE) != 0 && strcmp(service, PORT_STRING) != 0) {
306 -         snprintf(MAXS(tmp),"%s has no system SAFT server, "
307 +         snprintf(tmp,sizeof(tmp)-1,"%s has no system SAFT server, "
308                    "trying user SAFT server on port %s",host,service);
309           if (quiet<2) message(prg,'W',tmp);
310           sockfd=open_connection(host,service);
311 @@ -733,10 +733,10 @@ int saft_connect(const char *type,
312        
313      }
314      
315 -    if (sockfd==-1) snprintf(MAXS(tmp),"cannot create a network socket");
316 -    if (sockfd==-2) snprintf(MAXS(tmp),"cannot open connection to %s",host);
317 -    if (sockfd==-3) snprintf(MAXS(tmp),"%s is unknown",host);
318 -    if (sockfd==-4) snprintf(MAXS(tmp),"out of memory");
319 +    if (sockfd==-1) snprintf(tmp,sizeof(tmp)-1,"cannot create a network socket");
320 +    if (sockfd==-2) snprintf(tmp,sizeof(tmp)-1,"cannot open connection to %s",host);
321 +    if (sockfd==-3) snprintf(tmp,sizeof(tmp)-1,"%s is unknown",host);
322 +    if (sockfd==-4) snprintf(tmp,sizeof(tmp)-1,"out of memory");
323      if (sockfd<0) {
324        if (client) {
325         errno=0;
326 @@ -750,7 +750,7 @@ int saft_connect(const char *type,
327      /* no remote server or protocol error? */
328      sock_getline(sockfd,line);
329      if (!str_beq(line,"220 ") || !strstr(line,"SAFT")) {
330 -      snprintf(MAXS(tmp),"No SAFT server on port %s at %s",service,host);
331 +      snprintf(tmp,sizeof(tmp)-1,"No SAFT server on port %s at %s",service,host);
332        if ((cp=strrchr(tmp,':'))) *cp=0;
333        if (client) {
334         errno=0;
335 @@ -763,9 +763,9 @@ int saft_connect(const char *type,
336      }
337  
338      /* send constant header lines */
339 -    snprintf(MAXS(tmp),"FROM %s",user);
340 +    snprintf(tmp,sizeof(tmp)-1,"FROM %s",user);
341      sendheader(sockfd,tmp);
342 -    snprintf(MAXS(tmp),"TO %s",recipient);
343 +    snprintf(tmp,sizeof(tmp)-1,"TO %s",recipient);
344      sock_putline(sockfd,tmp);
345  
346      /* is there a forward set? */
347 diff --git a/src/fetchfile.c b/src/fetchfile.c
348 index bd9d3c7..cb12354 100644
349 --- a/src/fetchfile.c
350 +++ b/src/fetchfile.c
351 @@ -215,14 +215,14 @@ int main(int argc, char *argv[]) {
352    tmpdir=mktmpdir(verbose);
353  
354    /* set various file names and check user spool and configuration directory */
355 -  snprintf(MAXS(pgptmp),"%s/fetchfile.pgp",tmpdir);
356 -  snprintf(MAXS(userspool),SPOOL"/%s",pwe->pw_name);
357 +  snprintf(pgptmp,sizeof(pgptmp)-1,"%s/fetchfile.pgp",tmpdir);
358 +  snprintf(userspool,sizeof(userspool)-1,SPOOL"/%s",pwe->pw_name);
359    if (stat(userspool,&finfo)<0) sendfiled_test(pwe->pw_name);
360 -  snprintf(MAXS(userconfig),"%s/.sendfile",pwe->pw_dir);
361 -  snprintf(MAXS(tmp),"%s/config",userspool);
362 +  snprintf(userconfig,sizeof(userconfig)-1,"%s/.sendfile",pwe->pw_dir);
363 +  snprintf(tmp,sizeof(tmp)-1,"%s/config",userspool);
364    if (stat(userconfig,&finfo)<0 && stat(userspool,&finfo)==0)
365      symlink(tmp,userconfig);
366 -  snprintf(MAXS(tmp),"%s/.sfspool",pwe->pw_dir);
367 +  snprintf(tmp,sizeof(tmp)-1,"%s/.sfspool",pwe->pw_dir);
368    if (stat(tmp,&finfo)==0 && finfo.st_mode&S_IFDIR) strcpy(userspool,tmp);
369  
370    /* scan the command line on options */
371 @@ -303,7 +303,7 @@ int main(int argc, char *argv[]) {
372    /* check tmp files */
373    unlink(pgptmp);
374    if (stat(pgptmp,&finfo)==0) {
375 -    snprintf(MAXS(tmp),
376 +    snprintf(tmp,sizeof(tmp)-1,
377              "tmp-file %s does already exist and cannot be deleted",pgptmp);
378      message(prg,'F',tmp);
379    }
380 @@ -332,19 +332,19 @@ int main(int argc, char *argv[]) {
381    }
382  
383    /* check pgp key files */
384 -  snprintf(MAXS(tmp),"%s/private.pgp",userconfig);
385 +  snprintf(tmp,sizeof(tmp)-1,"%s/private.pgp",userconfig);
386    if (stat(tmp,&finfo)<0) {
387 -    snprintf(MAXS(line),"no access to %s (try 'fetchfile -I' first)",tmp);
388 +    snprintf(line,sizeof(line)-1,"no access to %s (try 'fetchfile -I' first)",tmp);
389      message(prg,'F',line);
390    }
391 -  snprintf(MAXS(tmp),"%s/public.pgp",userconfig);
392 +  snprintf(tmp,sizeof(tmp)-1,"%s/public.pgp",userconfig);
393    if (stat(tmp,&finfo)<0) {
394 -    snprintf(MAXS(line),"no access to %s (try 'fetchfile -I' first)",tmp);
395 +    snprintf(line,sizeof(line)-1,"no access to %s (try 'fetchfile -I' first)",tmp);
396      message(prg,'F',line);
397    }
398    
399    /* parse the user config-file */
400 -  snprintf(MAXS(tmp),"%s/config",userconfig);
401 +  snprintf(tmp,sizeof(tmp)-1,"%s/config",userconfig);
402    if ((inf=rfopen(tmp,"r"))) {
403      while (fgetl(line,inf)) {
404        
405 @@ -386,24 +386,24 @@ int main(int argc, char *argv[]) {
406  
407    if (!*id) strcpy(id,pwe->pw_name);
408    if (!*server) strcpy(server,"localhost");
409 -  snprintf(MAXS(listfile),"%s/%s@%s:fetch.lis",userspool,id,server);
410 +  snprintf(listfile,sizeof(listfile)-1,"%s/%s@%s:fetch.lis",userspool,id,server);
411    
412    /* initiate the connection to the server */
413    if (!*server) {
414      errno=0;
415      message(prg,'F',"no SAFT server is defined");
416    }
417 -  snprintf(MAXS(tmp),"connecting to SAFT server %s",server);
418 +  snprintf(tmp,sizeof(tmp)-1,"connecting to SAFT server %s",server);
419    if (quiet<2) message(prg,'I',tmp);
420  #ifndef ENABLE_MULTIPROTOCOL
421    sockfd=open_connection(server,SAFT);
422  #else
423    sockfd=open_connection(server,SERVICE);
424  #endif
425 -  if (sockfd==-1) snprintf(MAXS(tmp),"cannot create a network socket");
426 -  if (sockfd==-2) snprintf(MAXS(tmp),"cannot open connection to %s",server);
427 -  if (sockfd==-3) snprintf(MAXS(tmp),"%s is unknown",server);
428 -  if (sockfd==-4) snprintf(MAXS(tmp),"out of memory");
429 +  if (sockfd==-1) snprintf(tmp,sizeof(tmp)-1,"cannot create a network socket");
430 +  if (sockfd==-2) snprintf(tmp,sizeof(tmp)-1,"cannot open connection to %s",server);
431 +  if (sockfd==-3) snprintf(tmp,sizeof(tmp)-1,"%s is unknown",server);
432 +  if (sockfd==-4) snprintf(tmp,sizeof(tmp)-1,"out of memory");
433    if (sockfd<0) {
434      errno=0;
435      message(prg,'F',tmp);
436 @@ -413,22 +413,22 @@ int main(int argc, char *argv[]) {
437    sock_getline(sockfd,line);
438    if (!str_beq(line,"220 ") || !strstr(line,"SAFT")) {
439      errno=0;
440 -    snprintf(MAXS(tmp),"No SAFT server on port %d at %s",SAFT,server);
441 +    snprintf(tmp,sizeof(tmp)-1,"No SAFT server on port %d at %s",SAFT,server);
442      message(prg,'F',tmp);
443    }
444    
445    /* send ID */
446 -  snprintf(MAXS(tmp),"ID %s",id);
447 +  snprintf(tmp,sizeof(tmp)-1,"ID %s",id);
448    sock_putline(sockfd,tmp);
449    sock_getline(sockfd,line);
450    if (str_beq(line,"520")) {
451      errno=0;
452 -    snprintf(MAXS(tmp),"user %s is unknown on SAFT-server %s",id,server);
453 +    snprintf(tmp,sizeof(tmp)-1,"user %s is unknown on SAFT-server %s",id,server);
454      message(prg,'F',tmp);
455    }
456    if (!str_beq(line,"331")) {
457      errno=0;
458 -    snprintf(MAXS(tmp),"server error: %s",line+4);
459 +    snprintf(tmp,sizeof(tmp)-1,"server error: %s",line+4);
460      message(prg,'F',tmp);
461    }
462    str_trim(line);
463 @@ -440,7 +440,7 @@ int main(int argc, char *argv[]) {
464    outf=rfopen(pgptmp,"w");
465    if (!outf) {
466      errno=0;
467 -    snprintf(MAXS(tmp),"cannot open/write to %s",pgptmp);
468 +    snprintf(tmp,sizeof(tmp)-1,"cannot open/write to %s",pgptmp);
469      message(prg,'F',tmp);
470    }
471    fprintf(outf,"%s",cp+1);
472 @@ -448,13 +448,13 @@ int main(int argc, char *argv[]) {
473  
474    /* goto user spool directory */
475    if (chdir(userspool)<0) {
476 -    snprintf(MAXS(tmp),"cannot change to %s",userspool);
477 +    snprintf(tmp,sizeof(tmp)-1,"cannot change to %s",userspool);
478      message(prg,'F',tmp);
479    }
480    
481    /* call pgp */
482    /* DONT REMOVE 2>/dev/null IN THE FOLLOWING LINE! */
483 -  snprintf(MAXS(cmd),"cd %s; PGPPATH='.' %s -sbaf "
484 +  snprintf(cmd,sizeof(cmd)-1,"cd %s; PGPPATH='.' %s -sbaf "
485            "+secring=private.pgp +pubring=public.pgp <%s 2>/dev/null",
486            userconfig,pgp_bin,pgptmp);
487    if (verbose) printf("call: %s\n",cmd);
488 @@ -478,7 +478,7 @@ int main(int argc, char *argv[]) {
489    }
490    
491    iso2utf(tmp,response);
492 -  snprintf(MAXS(response),"AUTH %s",tmp);
493 +  snprintf(response,sizeof(response)-1,"AUTH %s",tmp);
494    sendheader(sockfd,response);
495  
496    /* config file transfer? */
497 @@ -492,7 +492,7 @@ int main(int argc, char *argv[]) {
498      if (*tmp == '/')
499        strcpy(conffile,tmp);
500      else
501 -      snprintf(MAXS(conffile),"%s/%s",swd,tmp);
502 +      snprintf(conffile,sizeof(conffile)-1,"%s/%s",swd,tmp);
503  
504      /* write config file */
505      if (wconf) {
506 @@ -501,23 +501,23 @@ int main(int argc, char *argv[]) {
507         cp++;
508        else
509         cp=conffile;
510 -      snprintf(MAXS(tmp),"CONF WRITE %s",cp);
511 +      snprintf(tmp,sizeof(tmp)-1,"CONF WRITE %s",cp);
512        sock_putline(sockfd,tmp);
513        sock_getline(sockfd,line);
514        if (!str_beq(line,"302 ") && !str_beq(line,"200 ")) {
515         errno=0;
516 -       snprintf(MAXS(tmp),"server error: %s",line+4);
517 +       snprintf(tmp,sizeof(tmp)-1,"server error: %s",line+4);
518         message(prg,'F',tmp);
519        }
520      
521        inf=rfopen(conffile,"r");
522        if (!inf) {
523 -       snprintf(MAXS(tmp),"cannot open %s",conffile);
524 +       snprintf(tmp,sizeof(tmp)-1,"cannot open %s",conffile);
525         message(prg,'F',tmp);
526        }
527  
528        if (quiet<2) {
529 -       snprintf(MAXS(tmp),"transfering %s",conffile);
530 +       snprintf(tmp,sizeof(tmp)-1,"transfering %s",conffile);
531         message(prg,'I',tmp);
532        }
533        
534 @@ -532,7 +532,7 @@ int main(int argc, char *argv[]) {
535        sock_getline(sockfd,line);
536        if (!str_beq(line,"201 ")) {
537         errno=0;
538 -       snprintf(MAXS(tmp),"server error: %s",line+4);
539 +       snprintf(tmp,sizeof(tmp)-1,"server error: %s",line+4);
540         message(prg,'F',tmp);
541        }
542      
543 @@ -542,12 +542,12 @@ int main(int argc, char *argv[]) {
544         cp++;
545        else
546         cp=conffile;
547 -      snprintf(MAXS(tmp),"CONF READ %s",cp);
548 +      snprintf(tmp,sizeof(tmp)-1,"CONF READ %s",cp);
549        sock_putline(sockfd,tmp);
550        while (sock_getline(sockfd,line)) {
551         if (!str_beq(line,"250")) {
552           errno=0;
553 -         snprintf(MAXS(tmp),"server error: %s",line+4);
554 +         snprintf(tmp,sizeof(tmp)-1,"server error: %s",line+4);
555           message(prg,'F',tmp);
556         }
557         if (str_beq("250 ",line)) break;
558 @@ -592,11 +592,11 @@ int main(int argc, char *argv[]) {
559        number=atoi(argv[i]);
560        if (del) {
561         if (delete_file(sockfd,number)<0) {
562 -         snprintf(MAXS(tmp),"cannot delete file #%d from server",number);
563 +         snprintf(tmp,sizeof(tmp)-1,"cannot delete file #%d from server",number);
564           errno=0;
565           message(prg,'E',prg);
566         } else {
567 -         snprintf(MAXS(tmp),"file #%d deleted from server",number);
568 +         snprintf(tmp,sizeof(tmp)-1,"file #%d deleted from server",number);
569           if (quiet<2) message(prg,'I',tmp);
570           n++;
571         }
572 @@ -616,7 +616,7 @@ int main(int argc, char *argv[]) {
573      get_list(sockfd,server,id,listf);
574      fclose(listf);
575    } else {
576 -    snprintf(MAXS(tmp),"cannot open %s for writing",listfile);
577 +    snprintf(tmp,sizeof(tmp)-1,"cannot open %s for writing",listfile);
578      message(prg,'F',tmp);
579    }
580  
581 @@ -624,7 +624,7 @@ int main(int argc, char *argv[]) {
582    if (all) {
583      listf=rfopen(listfile,"r");
584      if (!listf) {
585 -      snprintf(MAXS(tmp),"cannot open %s for reading",listfile);
586 +      snprintf(tmp,sizeof(tmp)-1,"cannot open %s for reading",listfile);
587        message(prg,'F',tmp);
588      }
589      while (fgetl(line,listf)) {
590 @@ -642,11 +642,11 @@ int main(int argc, char *argv[]) {
591         number=atoi(line);
592         if (del) {
593           if (delete_file(sockfd,number)<0) {
594 -           snprintf(MAXS(tmp),"cannot delete file #%d (%s) from server",number,fname);
595 +           snprintf(tmp,sizeof(tmp)-1,"cannot delete file #%d (%s) from server",number,fname);
596             errno=0;
597             message(prg,'E',prg);
598           } else {
599 -           snprintf(MAXS(tmp),"file #%d (%s) deleted from server",number,fname);
600 +           snprintf(tmp,sizeof(tmp)-1,"file #%d (%s) deleted from server",number,fname);
601             if (quiet<2) message(prg,'I',tmp);
602             n++;
603           }
604 @@ -666,7 +666,7 @@ int main(int argc, char *argv[]) {
605    for (i=optind;i<argc;i++) {
606      listf=rfopen(listfile,"r");
607      if (!listf) {
608 -      snprintf(MAXS(tmp),"cannot open %s for reading",listfile);
609 +      snprintf(tmp,sizeof(tmp)-1,"cannot open %s for reading",listfile);
610        message(prg,'F',tmp);
611      }
612      while (fgetl(line,listf)) {
613 @@ -683,11 +683,11 @@ int main(int argc, char *argv[]) {
614         number=atoi(line);
615         if (del) {
616           if (delete_file(sockfd,number)<0) {
617 -           snprintf(MAXS(tmp),"cannot delete file #%d (%s) from server",number,fname);
618 +           snprintf(tmp,sizeof(tmp)-1,"cannot delete file #%d (%s) from server",number,fname);
619             errno=0;
620             message(prg,'E',prg);
621           } else {
622 -           snprintf(MAXS(tmp),"file #%d (%s) deleted from server",number,fname);
623 +           snprintf(tmp,sizeof(tmp)-1,"file #%d (%s) deleted from server",number,fname);
624             if (quiet<2) message(prg,'I',tmp);
625             n++;
626           }
627 @@ -751,7 +751,7 @@ void rexit(int n) {
628      
629      /* change back to starting directory */
630      if (chdir(swd)<0) {
631 -      snprintf(MAXS(tmp),"cannot change back to %s",swd);
632 +      snprintf(tmp,sizeof(tmp)-1,"cannot change back to %s",swd);
633        message(prg,'E',tmp);
634      } else 
635        if (verbose) printf("shell-call: %s\n",rfilen);
636 @@ -776,7 +776,7 @@ int delete_file(int sockfd, int number) {
637    char line[MAXLEN];   /* one line of text */
638  
639    /* send LIST command */
640 -  snprintf(MAXS(line),"DEL %d",number);
641 +  snprintf(line,sizeof(line)-1,"DEL %d",number);
642    sock_putline(sockfd,line);
643    
644    sock_getline(sockfd,line);
645 @@ -827,7 +827,7 @@ int get_list(int sockfd, const char *server, const char *id, FILE *listf) {
646      /* invalid answer? */
647      if (!str_beq(line,"250")) {
648        errno=0;
649 -      snprintf(MAXS(tmp),"invalid answer from server: %s",line+4);
650 +      snprintf(tmp,sizeof(tmp)-1,"invalid answer from server: %s",line+4);
651        message(prg,'E',tmp);
652        return(n);
653      }
654 @@ -956,14 +956,14 @@ int get_file(int sockfd, int number, int ptso) {
655      if (!id) message(prg,'F',"cannot create local spool file");
656    
657      /* open spool header and data files */
658 -    snprintf(MAXS(shfile),"%d.h",id);
659 -    snprintf(MAXS(sdfile),"%d.d",id);
660 +    snprintf(shfile,sizeof(shfile)-1,"%d.h",id);
661 +    snprintf(sdfile,sizeof(sdfile)-1,"%d.d",id);
662      sdfd=open(sdfile,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR);
663      shfd=open(shfile,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR);
664      if (shfd<0 || sdfd<0) message(prg,'F',"cannot create local spool file");
665    }
666    
667 -  snprintf(MAXS(tmp),"GET HEADER %d",number);
668 +  snprintf(tmp,sizeof(tmp)-1,"GET HEADER %d",number);
669    sock_putline(sockfd,tmp);
670    
671    for (;;) {
672 @@ -981,7 +981,7 @@ int get_file(int sockfd, int number, int ptso) {
673         unlink(shfile);
674        }
675        errno=0;
676 -      snprintf(MAXS(tmp),"server-error: %s",line+4);
677 +      snprintf(tmp,sizeof(tmp)-1,"server-error: %s",line+4);
678        message(prg,'E',tmp);
679        return(-1);
680      }
681 @@ -1003,7 +1003,7 @@ int get_file(int sockfd, int number, int ptso) {
682      if (str_beq(line+4,"FROM")) {
683        if ((cp=strchr(line+10,' '))) {
684         *cp=0;
685 -       snprintf(MAXS(tmp),"%s (%s)",line+9,cp+1);
686 +       snprintf(tmp,sizeof(tmp)-1,"%s (%s)",line+9,cp+1);
687         *cp=' ';
688        } else
689         strcpy(tmp,line+9);
690 @@ -1050,15 +1050,15 @@ int get_file(int sockfd, int number, int ptso) {
691  
692    if (quiet<2) {
693      if (flp && flp->csize==offset) {
694 -      snprintf(MAXS(tmp),"file %d (%s) has been already fetched",number,fname);
695 +      snprintf(tmp,sizeof(tmp)-1,"file %d (%s) has been already fetched",number,fname);
696        message(prg,'I',tmp);
697      } else {
698        if (quiet==1) {
699         if (offset)
700 -         snprintf(MAXS(tmp),"resuming fetching file %d (%s) with %ld kB",
701 +         snprintf(tmp,sizeof(tmp)-1,"resuming fetching file %d (%s) with %ld kB",
702                    number,fname,(size+1023)/1024);
703         else
704 -         snprintf(MAXS(tmp),"fetching file %d (%s) with %ld kB",
705 +         snprintf(tmp,sizeof(tmp)-1,"fetching file %d (%s) with %ld kB",
706                    number,fname,(size+1023)/1024);
707         message(prg,'I',tmp);
708        }
709 @@ -1072,7 +1072,7 @@ int get_file(int sockfd, int number, int ptso) {
710      return(0);
711    }
712    
713 -  snprintf(MAXS(tmp),"GET FILE %d %ld",number,offset);
714 +  snprintf(tmp,sizeof(tmp)-1,"GET FILE %d %ld",number,offset);
715    sock_putline(sockfd,tmp);
716    sock_getline(sockfd,line);
717  
718 @@ -1084,7 +1084,7 @@ int get_file(int sockfd, int number, int ptso) {
719        unlink(shfile);
720      }
721      errno=0;
722 -    snprintf(MAXS(tmp),"server-error: %s",line+4);
723 +    snprintf(tmp,sizeof(tmp)-1,"server-error: %s",line+4);
724      message(prg,'E',tmp);
725      return(-1);
726    }
727 @@ -1096,7 +1096,7 @@ int get_file(int sockfd, int number, int ptso) {
728    
729    /* resend active? */
730    if (offset && quiet<2) {
731 -    snprintf(MAXS(tmp),"resuming at byte %ld",offset);
732 +    snprintf(tmp,sizeof(tmp)-1,"resuming at byte %ld",offset);
733      message("",'I',tmp);
734    }
735  
736 @@ -1154,10 +1154,10 @@ int get_file(int sockfd, int number, int ptso) {
737      if (quiet==1) {
738        
739        if (thruput>9999)
740 -       snprintf(MAXS(tmp),
741 +       snprintf(tmp,sizeof(tmp)-1,
742                  "transfer of %s completed: %.1f kB/s",fname,thruput/1024);
743        else
744 -       snprintf(MAXS(tmp),
745 +       snprintf(tmp,sizeof(tmp)-1,
746                  "transfer of %s completed: %d byte/s",fname,(int)thruput);
747        message("",'I',tmp);
748  
749 @@ -1204,10 +1204,10 @@ void init() {
750    printf("\nThis is the init routine for %s.\n",prg);
751    printf("It will create the necessary pgp files and the spool directory.\n");
752    printf("You can press Ctrl-C at any time to stop this procedure.\n\n");
753 -  snprintf(MAXS(userspool),SPOOL"/%s",pwe->pw_name);
754 +  snprintf(userspool,sizeof(userspool)-1,SPOOL"/%s",pwe->pw_name);
755    if (stat(userspool,&finfo)<0 || !(finfo.st_mode&S_IFDIR)) {
756      printf("User spool %s does not exist.\n",userspool);
757 -    snprintf(MAXS(userspool),"%s/.sfspool",pwe->pw_dir);
758 +    snprintf(userspool,sizeof(userspool)-1,"%s/.sfspool",pwe->pw_dir);
759      printf("May I create local spool %s? ",userspool);
760      fgetl(answer,stdin);
761      if (*answer!='y' && *answer!='Y') {
762 @@ -1233,7 +1233,7 @@ void init() {
763    }
764  
765    if (!(outf=rfopen(configf,"a"))) {
766 -    snprintf(MAXS(tmp),"cannot open %s",configf);
767 +    snprintf(tmp,sizeof(tmp)-1,"cannot open %s",configf);
768      message(prg,'F',tmp);
769    }
770    printf("What is the address of your SAFT server where you want to "
771 @@ -1299,11 +1299,11 @@ int sendfiled_test(const char *user) {
772    if (!str_beq(line,"220 ") || !strstr(line,"SAFT")) return(-1);
773     
774    /* test if you can receive messages */
775 -  snprintf(MAXS(line),"FROM %s",user);
776 +  snprintf(line,sizeof(line)-1,"FROM %s",user);
777    sock_putline(sockfd,line);
778    sock_getline(sockfd,line);
779    if (!str_beq(line,"200 ")) return(-1);
780 -  snprintf(MAXS(line),"TO %s",user);
781 +  snprintf(line,sizeof(line)-1,"TO %s",user);
782    sock_putline(sockfd,line);
783    sock_getline(sockfd,line);
784    if (!str_beq(line,"200 ")) return(-1);
785 diff --git a/src/io.c b/src/io.c
786 index 7e5814c..e011165 100644
787 --- a/src/io.c
788 +++ b/src/io.c
789 @@ -132,7 +132,7 @@ int fcopy(const char *from, const char *to, mode_t mode) {
790  
791    /* get the original file size */
792    if (stat(from,&finfo)<0) {
793 -    snprintf(MAXS(tmp),"cannot access '%s'",from);
794 +    snprintf(tmp,sizeof(tmp)-1,"cannot access '%s'",from);
795      message("",'E',tmp);
796      return(-1);
797    }
798 @@ -147,7 +147,7 @@ int fcopy(const char *from, const char *to, mode_t mode) {
799    /* open source file */
800    fdin=open(from,O_RDONLY|O_LARGEFILE,0);
801    if (fdin<0) {
802 -    snprintf(MAXS(tmp),"error opening '%s'",from);
803 +    snprintf(tmp,sizeof(tmp)-1,"error opening '%s'",from);
804      message("",'E',tmp);
805      return(-1);
806    }
807 @@ -158,7 +158,7 @@ int fcopy(const char *from, const char *to, mode_t mode) {
808      /* open destination file */
809      fdout=creat(to,mode);
810      if (fdout<0) {
811 -      snprintf(MAXS(tmp),"error creating '%s'",to);
812 +      snprintf(tmp,sizeof(tmp)-1,"error creating '%s'",to);
813        message("",'E',tmp);
814        close(fdin);
815        return(-1);
816 @@ -180,7 +180,7 @@ int fcopy(const char *from, const char *to, mode_t mode) {
817         close(fdin);
818         close(fdout);
819         free(buf);
820 -       snprintf(MAXS(tmp),"error writing '%s'",to);
821 +       snprintf(tmp,sizeof(tmp)-1,"error writing '%s'",to);
822         message("",'E',tmp);
823         return(-1);
824        }
825 @@ -212,7 +212,7 @@ int fcopy(const char *from, const char *to, mode_t mode) {
826  
827    /* read error? */
828    if (rbytes<0) {
829 -    snprintf(MAXS(tmp),"error reading '%s'",from);
830 +    snprintf(tmp,sizeof(tmp)-1,"error reading '%s'",from);
831      message("",'E',tmp);
832      return(-1);
833    }
834 @@ -220,7 +220,7 @@ int fcopy(const char *from, const char *to, mode_t mode) {
835    /* count mismatch or read/write errors? */
836    if (fsize!=wtotal) {
837      errno=0;
838 -    snprintf(MAXS(tmp),"wrong byte count for '%s'",from);
839 +    snprintf(tmp,sizeof(tmp)-1,"wrong byte count for '%s'",from);
840      message("",'E',tmp);
841      return(-1);
842    }
843 @@ -334,12 +334,12 @@ char *mktmpdir(int verbose) {
844    strcat(tmpdir,tmp);
845    
846    if (mkdir(tmpdir,S_IRWXU)<0 || chmod(tmpdir,S_IRWXU)<0) {
847 -    snprintf(MAXS(tmp),"cannot create tmpdir %s",tmpdir);
848 +    snprintf(tmp,sizeof(tmp)-1,"cannot create tmpdir %s",tmpdir);
849      message("",'F',tmp);
850    }
851    
852    if (verbose) {
853 -    snprintf(MAXS(tmp),"directory for temporary files is: %s",tmpdir);
854 +    snprintf(tmp,sizeof(tmp)-1,"directory for temporary files is: %s",tmpdir);
855      message("",'I',tmp);
856    }
857    
858 @@ -365,7 +365,7 @@ void rmtmpdir(char *tmpdir) {
859    /* open dir */
860    if (chdir(tmpdir) < 0 || !(dp=opendir(tmpdir))) {
861      /*
862 -    snprintf(MAXS(tmp),"cleanup: cannot open %s",tmpdir);
863 +    snprintf(tmp,sizeof(tmp)-1,"cleanup: cannot open %s",tmpdir);
864      message("",'X',tmp);
865       */
866      return;
867 @@ -378,7 +378,7 @@ void rmtmpdir(char *tmpdir) {
868  
869      /* delete file */
870      if (unlink(dire->d_name) < 0) {
871 -      snprintf(MAXS(tmp),"cannot remove %s/%s",tmpdir,dire->d_name);
872 +      snprintf(tmp,sizeof(tmp)-1,"cannot remove %s/%s",tmpdir,dire->d_name);
873        message("",'W',tmp);
874      }
875      
876 @@ -386,7 +386,7 @@ void rmtmpdir(char *tmpdir) {
877  
878    chdir(cwd);
879    if (rmdir(tmpdir) < 0) {
880 -    snprintf(MAXS(tmp),"cannot remove %s",tmpdir);
881 +    snprintf(tmp,sizeof(tmp)-1,"cannot remove %s",tmpdir);
882      message("",'X',tmp);
883    }
884    
885 @@ -483,7 +483,7 @@ int vsystem(const char *cmd) {
886    extern char *prg;
887    
888    if (verbose) {
889 -    snprintf(MAXS(tmp),"shell-call: %s\n",cmd);
890 +    snprintf(tmp,sizeof(tmp)-1,"shell-call: %s\n",cmd);
891      message(prg,'I',tmp);
892    }
893    return(system(cmd));
894 @@ -506,8 +506,8 @@ FILE* vpopen(const char *cmd, const char *type) {
895    if (verbose) {
896      *tmp = 0;
897      switch (*type) {
898 -      case 'r': snprintf(MAXS(tmp),"shell-call: %s|",cmd); break;
899 -      case 'w': snprintf(MAXS(tmp),"shell-call: |%s",cmd); break;
900 +      case 'r': snprintf(tmp,sizeof(tmp)-1,"shell-call: %s|",cmd); break;
901 +      case 'w': snprintf(tmp,sizeof(tmp)-1,"shell-call: |%s",cmd); break;
902      }
903      message(prg,'I',tmp);
904    }
905 diff --git a/src/net.c b/src/net.c
906 index eed63ac..64fcbcf 100644
907 --- a/src/net.c
908 +++ b/src/net.c
909 @@ -458,7 +458,7 @@ int sock_getline(int fd, char *line) {
910    if (n+1==MAXLEN && line[n] != '\n') {
911      if (client) {
912        errno=0;
913 -      snprintf(MAXS(tmp),"network socket data overrun (read bytes: %d)",n);
914 +      snprintf(tmp,sizeof(tmp)-1,"network socket data overrun (read bytes: %d)",n);
915        message("",'E',tmp);
916        message("",'F',line);
917      }
918 @@ -530,7 +530,7 @@ char *getreply(int fd) {
919        if (len<0) {
920         errno=0;
921         strcpy(msg,"server has closed the connection");
922 -       if (*reply) snprintf(MAXS(msg),"%s, last data: \"%s\"",msg,reply);
923 +       if (*reply) snprintf(msg,sizeof(msg)-1,"%s, last data: \"%s\"",msg,reply);
924         if (client) {
925           errno=0;
926           message("",'F',msg);
927 @@ -542,7 +542,7 @@ char *getreply(int fd) {
928        /* reply message too short? */
929        if (len<4) {
930         errno=0;
931 -       snprintf(MAXS(msg),"corrupt reply: \"%s\"",reply);
932 +       snprintf(msg,sizeof(msg)-1,"corrupt reply: \"%s\"",reply);
933         if (client) {
934           errno=0;
935            if (xonf) {
936 @@ -565,7 +565,7 @@ char *getreply(int fd) {
937    /* fatal server error? */
938    if (reply[0]=='4') {
939      errno=0;
940 -    snprintf(MAXS(msg),"server error: %s",&reply[4]);
941 +    snprintf(msg,sizeof(msg)-1,"server error: %s",&reply[4]);
942      if (client) {
943        errno=0;
944        if (xonf) {
945 @@ -640,7 +640,7 @@ int sendheader(int fd, char *line) {
946    if (str_beq(reply,"202")) return(1);
947    
948    errno=0;
949 -  snprintf(MAXS(msg),"server error: %s",&reply[4]);
950 +  snprintf(msg,sizeof(msg)-1,"server error: %s",&reply[4]);
951    message(prg,'F',msg);
952                     
953    return(-1);
954 @@ -725,7 +725,7 @@ int send_data(int sockfd, off_t size, const char *file,
955         if (!str_beq(reply,"230 ")) {
956           if (quiet<3) {
957             errno=0;
958 -           snprintf(MAXS(tmp),"server error: %s",&reply[4]);
959 +           snprintf(tmp,sizeof(tmp)-1,"server error: %s",&reply[4]);
960             message("",'F',tmp);
961           }
962           return(-1);
963 @@ -742,7 +742,7 @@ int send_data(int sockfd, off_t size, const char *file,
964  
965      /* file already transmitted? */
966      if (str_beq(reply,"531 ")) {
967 -      snprintf(MAXS(tmp),
968 +      snprintf(tmp,sizeof(tmp)-1,
969                "file %s has been already transmitted - ignored.",iso_name);
970        if (quiet<2) message("",'W',tmp);
971        return(1);
972 @@ -751,7 +751,7 @@ int send_data(int sockfd, off_t size, const char *file,
973      /* server reply ok? */
974      if (!str_beq(reply,"302 ")) {
975        if (quiet<3) {
976 -       snprintf(MAXS(tmp),"corrupt server reply: %s",&reply[4]);
977 +       snprintf(tmp,sizeof(tmp)-1,"corrupt server reply: %s",&reply[4]);
978         errno=0;
979         message("",'F',tmp);
980        }
981 @@ -764,7 +764,7 @@ int send_data(int sockfd, off_t size, const char *file,
982      ffd=open(file,O_RDONLY,0);
983      if (ffd<0 || lseek(ffd,offset,SEEK_SET)<0) {
984        if (quiet<3) {
985 -       snprintf(MAXS(tmp),"error reading %s",iso_name);
986 +       snprintf(tmp,sizeof(tmp)-1,"error reading %s",iso_name);
987         message("",'E',tmp);
988        }
989        return(-1);
990 @@ -775,12 +775,12 @@ int send_data(int sockfd, off_t size, const char *file,
991  
992    /* resend active? */
993    if (offset) {
994 -    snprintf(MAXS(tmp),"resuming %s at byte %lld",iso_name,offset);
995 +    snprintf(tmp,sizeof(tmp)-1,"resuming %s at byte %lld",iso_name,offset);
996      if (quiet<2) message("",'I',tmp);
997    }
998  
999    if (quiet==1) {
1000 -    snprintf(MAXS(tmp),"begin transfer of %s with %lld bytes",fname,size);
1001 +    snprintf(tmp,sizeof(tmp)-1,"begin transfer of %s with %lld bytes",fname,size);
1002      message("",'I',tmp);
1003    }
1004  
1005 @@ -805,7 +805,7 @@ int send_data(int sockfd, off_t size, const char *file,
1006      if (readn(ffd,packet,packet_size)<packet_size) {
1007        if (quiet<3) {
1008          if (!quiet) printf("\n");
1009 -       snprintf(MAXS(tmp),"error reading %s",iso_name);
1010 +       snprintf(tmp,sizeof(tmp)-1,"error reading %s",iso_name);
1011         message("",'E',tmp);
1012        }
1013        close(ffd);
1014 @@ -844,7 +844,7 @@ int send_data(int sockfd, off_t size, const char *file,
1015    if ((n=size-nblocks*packet_size) > 0) {
1016      if (readn(ffd,packet,n)<n) {
1017        if (quiet<3) {
1018 -        snprintf(MAXS(tmp),"error reading %s",iso_name);
1019 +        snprintf(tmp,sizeof(tmp)-1,"error reading %s",iso_name);
1020         message("",'E',tmp);
1021        }
1022        close(ffd);
1023 @@ -882,10 +882,10 @@ int send_data(int sockfd, off_t size, const char *file,
1024      if (quiet==1) {
1025        
1026        if (thruput>9999)
1027 -       snprintf(MAXS(tmp),
1028 +       snprintf(tmp,sizeof(tmp)-1,
1029                  "transfer of %s completed: %.1f kB/s",fname,thruput/1024);
1030        else
1031 -       snprintf(MAXS(tmp),
1032 +       snprintf(tmp,sizeof(tmp)-1,
1033                  "transfer of %s completed: %d byte/s",fname,(int)thruput);
1034        message("",'I',tmp);
1035  
1036 @@ -909,7 +909,7 @@ int send_data(int sockfd, off_t size, const char *file,
1037    /* transfer ok? */
1038    if (sockfd && !str_beq(getreply(sockfd),"201 ")) {
1039      if (quiet<3) {
1040 -      snprintf(MAXS(tmp),"transfer failed for %s",iso_name);
1041 +      snprintf(tmp,sizeof(tmp)-1,"transfer failed for %s",iso_name);
1042        errno=0;
1043        message("",'E',tmp);
1044      }
1045 diff --git a/src/receive.c b/src/receive.c
1046 index 50ae63e..96501b1 100644
1047 --- a/src/receive.c
1048 +++ b/src/receive.c
1049 @@ -287,11 +287,11 @@ int main(int argc, char *argv[]) {
1050          case 'q': quiet=1; break;
1051          case 'p': preserve=1; break;
1052          case 'H': header=1; break;
1053 -        case 'S': snprintf(MAXS(pgpring),"%s",optarg); break;
1054 +        case 'S': snprintf(pgpring,sizeof(pgpring)-1,"%s",optarg); break;
1055          case 'v': opt_v="-v"; verbose=1; break;
1056 -        case 'f': snprintf(MAXS(from),"%s",optarg); break;
1057 -        case 'b': snprintf(MAXS(bounce),"%s",optarg); break;
1058 -        case 'Z': snprintf(MAXS(userspool),"%s",optarg); break;
1059 +        case 'f': snprintf(from,sizeof(from)-1,"%s",optarg); break;
1060 +        case 'b': snprintf(bounce,sizeof(bounce)-1,"%s",optarg); break;
1061 +        case 'Z': snprintf(userspool,sizeof(userspool)-1,"%s",optarg); break;
1062          case 'V': message(prg,'I',"version "VERSION" revision "REVISION"");
1063                   exit(0);
1064      }
1065 @@ -318,18 +318,18 @@ int main(int argc, char *argv[]) {
1066    /* determine the spool directory */
1067    if (!*userspool) {
1068      if ((cp=getenv("SF_SPOOL"))) {
1069 -      snprintf(MAXS(userspool),"%s",cp);
1070 +      snprintf(userspool,sizeof(userspool)-1,"%s",cp);
1071      } else {
1072 -      snprintf(MAXS(userspool),"%s/.sfspool",pwe->pw_dir);
1073 +      snprintf(userspool,sizeof(userspool)-1,"%s/.sfspool",pwe->pw_dir);
1074        if (stat(userspool,&finfo)<0 || !(finfo.st_mode&S_IFDIR))
1075 -       snprintf(MAXS(userspool),SPOOL"/%s",pwe->pw_name);
1076 +       snprintf(userspool,sizeof(userspool)-1,SPOOL"/%s",pwe->pw_name);
1077      }
1078    }
1079 -  if (*userspool=='Z') snprintf(MAXS(userspool),SPOOL"/%s",pwe->pw_name);
1080 +  if (*userspool=='Z') snprintf(userspool,sizeof(userspool)-1,SPOOL"/%s",pwe->pw_name);
1081  
1082    /* does the spool directory exist? */
1083    if (stat(userspool,&finfo)<0 || (finfo.st_mode&S_IFMT)!=S_IFDIR) {
1084 -    snprintf(MAXS(tmp),"spool directory %s does not exist",userspool);
1085 +    snprintf(tmp,sizeof(tmp)-1,"spool directory %s does not exist",userspool);
1086      errno=0;
1087      message(prg,'E',tmp);
1088      exit(1);
1089 @@ -337,7 +337,7 @@ int main(int argc, char *argv[]) {
1090  
1091    /* correct permissions for the spool directory? */
1092    if (!(finfo.st_mode&S_IRWXU) || finfo.st_uid!=getuid()) {
1093 -    snprintf(MAXS(tmp),
1094 +    snprintf(tmp,sizeof(tmp)-1,
1095              "no access to spool directory %s (wrong permissions)",
1096              userspool);
1097      errno=0;
1098 @@ -348,7 +348,7 @@ int main(int argc, char *argv[]) {
1099    /* are there any files to receive? */
1100    sls=scanspool(from);
1101    if (sls==NULL) {
1102 -    snprintf(MAXS(tmp),"no files found in spool directory %s",userspool);
1103 +    snprintf(tmp,sizeof(tmp)-1,"no files found in spool directory %s",userspool);
1104      message(prg,'W',tmp);
1105      exit(1);
1106    }
1107 @@ -359,7 +359,7 @@ int main(int argc, char *argv[]) {
1108    }
1109  
1110    /* set log file read status (st_atime) for xhoppel */
1111 -  snprintf(MAXS(tmp),"%s/log",userspool);
1112 +  snprintf(tmp,sizeof(tmp)-1,"%s/log",userspool);
1113    inf=rfopen(tmp,"r");
1114    if (inf) {
1115      fgetl(tmp,inf);
1116 @@ -420,15 +420,15 @@ int main(int argc, char *argv[]) {
1117  
1118    /* set tmp file names */
1119    tmpdir=mktmpdir(strlen(opt_v));
1120 -  snprintf(MAXS(tartmp),"%s/receive.tar",tmpdir);
1121 -  snprintf(MAXS(fileslist),"%s/files",tmpdir);
1122 -  snprintf(MAXS(error_log),"%s/error.log",tmpdir);
1123 +  snprintf(tartmp,sizeof(tartmp)-1,"%s/receive.tar",tmpdir);
1124 +  snprintf(fileslist,sizeof(fileslist)-1,"%s/files",tmpdir);
1125 +  snprintf(error_log,sizeof(error_log)-1,"%s/error.log",tmpdir);
1126  
1127  
1128    /* list files? */
1129    if (listformat) {
1130      if (list(sls,listformat,from,pgpring,number,argc,argv)<0) {
1131 -      snprintf(MAXS(tmp),"no files in spool directory %s",userspool);
1132 +      snprintf(tmp,sizeof(tmp)-1,"no files in spool directory %s",userspool);
1133        message(prg,'W',tmp);
1134      }
1135      cleanup();
1136 @@ -456,10 +456,10 @@ int main(int argc, char *argv[]) {
1137               delete_sf(flp,1);
1138             else if (*bounce) {
1139               if (*bouncelist) {
1140 -               snprintf(MAXS(tmp),"%s %d",bouncelist,id);
1141 +               snprintf(tmp,sizeof(tmp)-1,"%s %d",bouncelist,id);
1142                 strcpy(bouncelist,tmp);
1143               } else {
1144 -               snprintf(MAXS(bouncelist),"%d",id);
1145 +               snprintf(bouncelist,sizeof(bouncelist)-1,"%d",id);
1146               }
1147             } else {
1148               receive_sf(flp,pgpring,header);
1149 @@ -473,7 +473,7 @@ int main(int argc, char *argv[]) {
1150  
1151        /* not found? */
1152        if (!found && id) {
1153 -        snprintf(MAXS(tmp),"spool file #%d not found",id);
1154 +        snprintf(tmp,sizeof(tmp)-1,"spool file #%d not found",id);
1155         message(prg,'W',tmp);
1156         status=1;
1157        }
1158 @@ -509,10 +509,10 @@ int main(int argc, char *argv[]) {
1159               delete_sf(flp,1);
1160             else if (*bounce) {
1161               if (*bouncelist) {
1162 -               snprintf(MAXS(tmp),"%s %d",bouncelist,flp->id);
1163 +               snprintf(tmp,sizeof(tmp)-1,"%s %d",bouncelist,flp->id);
1164                 strcpy(bouncelist,tmp);
1165               } else
1166 -               snprintf(MAXS(bouncelist),"%d",flp->id);
1167 +               snprintf(bouncelist,sizeof(bouncelist)-1,"%d",flp->id);
1168             } else
1169               receive_sf(flp,pgpring,header);
1170  
1171 @@ -524,7 +524,7 @@ int main(int argc, char *argv[]) {
1172  
1173        /* not found? */
1174        if (!found && !all) {
1175 -        snprintf(MAXS(tmp),"file %s not found",pattern);
1176 +        snprintf(tmp,sizeof(tmp)-1,"file %s not found",pattern);
1177         message(prg,'W',tmp);
1178         status=1;
1179        }
1180 @@ -537,10 +537,10 @@ int main(int argc, char *argv[]) {
1181    /* files to bounce? */
1182    if (*bounce && *bouncelist) {
1183      if (keep)
1184 -      snprintf(MAXS(tmp),
1185 +      snprintf(tmp,sizeof(tmp)-1,
1186                "sendfile -bk=y %s %s %s",opt_v,bouncelist,bounce);
1187      else
1188 -      snprintf(MAXS(tmp),
1189 +      snprintf(tmp,sizeof(tmp)-1,
1190                "sendfile -bk=n %s %s %s",opt_v,bouncelist,bounce);
1191      vsystem(tmp);
1192    }
1193 @@ -668,17 +668,17 @@ int list(struct senderlist *sls, int format, char *from, char *pgpring,
1194          
1195           /* encrypted, compressed or normal tar file? */
1196           if (flp->flags&F_CRYPT)
1197 -           snprintf(MAXS(showtar),"%s %s -f < %s/%d.d | %s tvf -",
1198 +           snprintf(showtar,sizeof(showtar)-1,"%s %s -f < %s/%d.d | %s tvf -",
1199                       pgp_bin,pgpvm,userspool,flp->id,tar_bin);
1200           else if (flp->flags&F_COMPRESS) {
1201             if (str_eq(flp->compress,S_BZIP2))
1202 -             snprintf(MAXS(showtar),"%s -d < %s/%d.d | %s tvf -",
1203 +             snprintf(showtar,sizeof(showtar)-1,"%s -d < %s/%d.d | %s tvf -",
1204                        bzip2_bin,userspool,flp->id,tar_bin);
1205             else
1206 -             snprintf(MAXS(showtar),"%s -d < %s/%d.d | %s tvf -",
1207 +             snprintf(showtar,sizeof(showtar)-1,"%s -d < %s/%d.d | %s tvf -",
1208                        gzip_bin,userspool,flp->id,tar_bin);
1209           } else {
1210 -           snprintf(MAXS(showtar),"%s tvf %s/%d.d",tar_bin,userspool,flp->id);
1211 +           snprintf(showtar,sizeof(showtar)-1,"%s tvf %s/%d.d",tar_bin,userspool,flp->id);
1212           }
1213  
1214           /* sneak inside... */
1215 @@ -760,16 +760,16 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1216    if (*pgpring) {
1217      switch (check_signature(flp,pgpring,0)) {
1218         case 1:  break;
1219 -       case 0:  snprintf(MAXS(tmp),"no signature found for '%s'",nname);
1220 +       case 0:  snprintf(tmp,sizeof(tmp)-1,"no signature found for '%s'",nname);
1221                   errno=0;
1222                   message(prg,'E',tmp);
1223                   return;
1224 -       case -1: snprintf(MAXS(tmp),"no public key found to check "
1225 +       case -1: snprintf(tmp,sizeof(tmp)-1,"no public key found to check "
1226                           "signature for '%s'",nname);
1227                   errno=0;
1228                   message(prg,'E',tmp);
1229                   return;
1230 -       case -2: snprintf(MAXS(tmp),"bad signature for '%s'",nname);
1231 +       case -2: snprintf(tmp,sizeof(tmp)-1,"bad signature for '%s'",nname);
1232                   errno=0;
1233                   message(prg,'E',tmp);
1234                  return;
1235 @@ -785,7 +785,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1236  
1237    /* show only the header? */
1238    if (header) {
1239 -    snprintf(MAXS(tmp),"%s/%d.h",userspool,flp->id);
1240 +    snprintf(tmp,sizeof(tmp)-1,"%s/%d.h",userspool,flp->id);
1241      printf("%d) %s\n",flp->id,nname);
1242      inf=rfopen(tmp,"r");
1243      while (fgetl(line,inf)) printf("%s",line);
1244 @@ -799,10 +799,10 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1245      
1246      /* encrypted spool file? */
1247      if (flp->flags&F_CRYPT) {
1248 -      snprintf(MAXS(cmd),"%s %s -f < %s/%d.d",pgp_bin,pgpvm,userspool,flp->id);
1249 +      snprintf(cmd,sizeof(cmd)-1,"%s %s -f < %s/%d.d",pgp_bin,pgpvm,userspool,flp->id);
1250        if (vsystem(cmd)!=0) {
1251          errno=0;
1252 -       snprintf(MAXS(tmp),"cannot decrypt '%s' :",nname);
1253 +       snprintf(tmp,sizeof(tmp)-1,"cannot decrypt '%s' :",nname);
1254         message(prg,'E',tmp);
1255         return;
1256        }
1257 @@ -810,12 +810,12 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1258      /* compressed spool file? */
1259      else if (flp->flags&F_COMPRESS) {
1260        if (str_eq(flp->compress,S_BZIP2))
1261 -       snprintf(MAXS(cmd),"%s -d < %s/%d.d",bzip2_bin,userspool,flp->id);
1262 +       snprintf(cmd,sizeof(cmd)-1,"%s -d < %s/%d.d",bzip2_bin,userspool,flp->id);
1263        else
1264 -       snprintf(MAXS(cmd),"%s -d < %s/%d.d",gzip_bin,userspool,flp->id);
1265 +       snprintf(cmd,sizeof(cmd)-1,"%s -d < %s/%d.d",gzip_bin,userspool,flp->id);
1266        if (vsystem(cmd)!=0 && !(flp->flags&F_TAR)) {
1267          errno=0;
1268 -       snprintf(MAXS(tmp),"cannot decompress '%s' :",nname);
1269 +       snprintf(tmp,sizeof(tmp)-1,"cannot decompress '%s' :",nname);
1270         message(prg,'E',tmp);
1271         return;
1272        }
1273 @@ -823,10 +823,10 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1274      else /* copy spool file to stdout */ {
1275        
1276        /* copy file */
1277 -      snprintf(MAXS(tmp),"%s/%d.d",userspool,flp->id);
1278 +      snprintf(tmp,sizeof(tmp)-1,"%s/%d.d",userspool,flp->id);
1279        if (fcopy(tmp,"",0)<0) {
1280          errno=0;
1281 -       snprintf(MAXS(tmp),"cannot read '%s'",nname);
1282 +       snprintf(tmp,sizeof(tmp)-1,"cannot read '%s'",nname);
1283          message(prg,'E',tmp);
1284         return;
1285        }
1286 @@ -865,9 +865,9 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1287        if (!quiet && checkfile(utf,fname,nname,sname,&overwrite)) return;
1288  
1289        /* copy file */
1290 -      snprintf(MAXS(tmp),"%s/%d.d",userspool,flp->id);
1291 +      snprintf(tmp,sizeof(tmp)-1,"%s/%d.d",userspool,flp->id);
1292        if (fcopy(tmp,fname,0666&~cmask)<0) {
1293 -        snprintf(MAXS(tmp),"cannot receive '%s'",nname);
1294 +        snprintf(tmp,sizeof(tmp)-1,"cannot receive '%s'",nname);
1295         errno=0;
1296          message(prg,'E',tmp);
1297         return;
1298 @@ -877,7 +877,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1299        create_sigfile(flp->sign,fname,nname,&overwrite);
1300  
1301        if (!keep) delete_sf(flp,0);
1302 -      snprintf(MAXS(tmp),"'%s' received",nname);
1303 +      snprintf(tmp,sizeof(tmp)-1,"'%s' received",nname);
1304        message(prg,'I',tmp);
1305  
1306        return;
1307 @@ -886,14 +886,14 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1308      /* encrypted tar spool file? */
1309      if (flp->flags&F_CRYPT) {
1310        
1311 -      snprintf(MAXS(cmd),"%s %s -f < %s/%d.d > %s",
1312 +      snprintf(cmd,sizeof(cmd)-1,"%s %s -f < %s/%d.d > %s",
1313               pgp_bin,pgpvm,userspool,flp->id,tartmp);
1314  
1315        /* create temporary decrypted tar file */
1316        vsystem(cmd);
1317        if (stat(tartmp,&finfo)<0 || finfo.st_size==0) {
1318          errno=0;
1319 -       snprintf(MAXS(tmp),"cannot decrypt '%s' :",nname);
1320 +       snprintf(tmp,sizeof(tmp)-1,"cannot decrypt '%s' :",nname);
1321         message(prg,'E',tmp);
1322         return;
1323        }
1324 @@ -914,15 +914,15 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1325      /* compressed, encrypted or normal tar file? */
1326      if (flp->flags&F_COMPRESS) {
1327        if (str_eq(flp->compress,S_BZIP2))
1328 -       snprintf(MAXS(cmd),"%s -d < %s/%d.d | %s tvf -",
1329 +       snprintf(cmd,sizeof(cmd)-1,"%s -d < %s/%d.d | %s tvf -",
1330                  bzip2_bin,userspool,flp->id,tar_bin);
1331        else
1332 -       snprintf(MAXS(cmd),"%s -d < %s/%d.d | %s tvf -",
1333 +       snprintf(cmd,sizeof(cmd)-1,"%s -d < %s/%d.d | %s tvf -",
1334                  gzip_bin,userspool,flp->id,tar_bin);
1335      } else if (flp->flags&F_CRYPT) {
1336 -      snprintf(MAXS(cmd),"%s tvf %s",tar_bin,tartmp);
1337 +      snprintf(cmd,sizeof(cmd)-1,"%s tvf %s",tar_bin,tartmp);
1338      } else {
1339 -      snprintf(MAXS(cmd),"%s tvf %s/%d.d",tar_bin,userspool,flp->id);
1340 +      snprintf(cmd,sizeof(cmd)-1,"%s tvf %s/%d.d",tar_bin,userspool,flp->id);
1341      }
1342  
1343      /* open pipe to read tar file-info */
1344 @@ -949,15 +949,15 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1345      /* compressed, encrypted or normal tar file? */
1346      if (flp->flags&F_COMPRESS) {
1347        if (str_eq(flp->compress,S_BZIP2))
1348 -       snprintf(MAXS(cmd),"%s -d < %s/%d.d | %s tf -",
1349 +       snprintf(cmd,sizeof(cmd)-1,"%s -d < %s/%d.d | %s tf -",
1350                  bzip2_bin,userspool,flp->id,tar_bin);
1351        else
1352 -       snprintf(MAXS(cmd),"%s -d < %s/%d.d | %s tf -",
1353 +       snprintf(cmd,sizeof(cmd)-1,"%s -d < %s/%d.d | %s tf -",
1354                  gzip_bin,userspool,flp->id,tar_bin);
1355      } else if (flp->flags&F_CRYPT) {
1356 -      snprintf(MAXS(cmd),"%s tf %s",tar_bin,tartmp);
1357 +      snprintf(cmd,sizeof(cmd)-1,"%s tf %s",tar_bin,tartmp);
1358      } else {
1359 -      snprintf(MAXS(cmd),"%s tf %s/%d.d",tar_bin,userspool,flp->id);
1360 +      snprintf(cmd,sizeof(cmd)-1,"%s tf %s/%d.d",tar_bin,userspool,flp->id);
1361      }
1362  
1363      /* open pipe to read tar file-info */
1364 @@ -1016,21 +1016,21 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1365      }
1366  
1367      /* receive from tar file */
1368 -    snprintf(MAXS(tmp),"receiving from archive '%s' :",nname);
1369 +    snprintf(tmp,sizeof(tmp)-1,"receiving from archive '%s' :",nname);
1370      message(prg,'I',tmp);
1371  
1372      /* compressed, encrypted or normal tar file? */
1373      if (flp->flags&F_COMPRESS) {
1374        if (str_eq(flp->compress,S_BZIP2))
1375 -       snprintf(MAXS(cmd),"%s -d < %s/%d.d | %s xvf - 2>%s",
1376 +       snprintf(cmd,sizeof(cmd)-1,"%s -d < %s/%d.d | %s xvf - 2>%s",
1377                  bzip2_bin,userspool,flp->id,tar_bin,error_log);
1378        else
1379 -       snprintf(MAXS(cmd),"%s -d < %s/%d.d | %s xvf - 2>%s",
1380 +       snprintf(cmd,sizeof(cmd)-1,"%s -d < %s/%d.d | %s xvf - 2>%s",
1381                  gzip_bin,userspool,flp->id,tar_bin,error_log);
1382      } else if (flp->flags&F_CRYPT)
1383 -      snprintf(MAXS(cmd),"%s xvf %s 2>%s",tar_bin,tartmp,error_log);
1384 +      snprintf(cmd,sizeof(cmd)-1,"%s xvf %s 2>%s",tar_bin,tartmp,error_log);
1385      else
1386 -      snprintf(MAXS(cmd),"%s xvf %s/%d.d 2>%s",
1387 +      snprintf(cmd,sizeof(cmd)-1,"%s xvf %s/%d.d 2>%s",
1388                tar_bin,userspool,flp->id,error_log);
1389  
1390      /* receive tar archive and check for errors */
1391 @@ -1044,7 +1044,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1392             !simplematch(line,TAR": Could not create symlink*File exists*",1)) {
1393           if (!terr) {
1394             terr=1;
1395 -           snprintf(MAXS(tmp),"errors while receive '%s' :",nname);
1396 +           snprintf(tmp,sizeof(tmp)-1,"errors while receive '%s' :",nname);
1397             message(prg,'E',tmp);
1398           }
1399           printf("%s",line);
1400 @@ -1055,7 +1055,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1401  
1402      /* was there an error with tar? */
1403      if (terr) {
1404 -      snprintf(MAXS(tmp),"leaving '%s' in spool intact",nname);
1405 +      snprintf(tmp,sizeof(tmp)-1,"leaving '%s' in spool intact",nname);
1406        message(prg,'I',tmp);
1407      } else {
1408       
1409 @@ -1108,7 +1108,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1410    /* safety fallback: try to delete an old file with the same name */
1411    unlink(fname);
1412    if (stat(fname,&finfo)==0) {
1413 -    snprintf(MAXS(tmp),"cannot create '%s' : "
1414 +    snprintf(tmp,sizeof(tmp)-1,"cannot create '%s' : "
1415              "file does already exist and is not deletable",fname);
1416      errno=0;
1417      message(prg,'E',tmp);
1418 @@ -1119,16 +1119,16 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1419    if (preserve && flp->flags&F_CRYPT) {
1420     
1421      /* copy file */
1422 -    snprintf(MAXS(tmp),"%s/%d.d",userspool,flp->id);
1423 +    snprintf(tmp,sizeof(tmp)-1,"%s/%d.d",userspool,flp->id);
1424      if (fcopy(tmp,fname,0666&~cmask)<0) {
1425 -      snprintf(MAXS(tmp),"cannot receive '%s'",nname);
1426 +      snprintf(tmp,sizeof(tmp)-1,"cannot receive '%s'",nname);
1427        errno=0;
1428        message(prg,'E',tmp);
1429        return;
1430      }
1431  
1432      if ((flp->flags&F_SOURCE || flp->flags&F_TEXT) && !quiet) {
1433 -      snprintf(MAXS(tmp),
1434 +      snprintf(tmp,sizeof(tmp)-1,
1435                "'%s' has a SOURCE or TEXT attribute, you have to decode it "
1436                "after pgp-decrypting with:  recode %s:"CHARSET" '%s'",
1437                nname,flp->charset,nname);
1438 @@ -1136,7 +1136,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1439      }
1440  
1441      if (flp->flags&F_MIME && !quiet) {
1442 -      snprintf(MAXS(tmp),
1443 +      snprintf(tmp,sizeof(tmp)-1,
1444                "'%s' has the MIME attribute, you have to run it through"
1445                "metamail after pgp-decrypting",nname);
1446        message(prg,'W',tmp);
1447 @@ -1146,7 +1146,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1448      create_sigfile(flp->sign,fname,nname,&overwrite);
1449  
1450      if (!keep) delete_sf(flp,0);
1451 -    snprintf(MAXS(tmp),"'%s' received",nname);
1452 +    snprintf(tmp,sizeof(tmp)-1,"'%s' received",nname);
1453      message(prg,'I',tmp);
1454  
1455      return;
1456 @@ -1161,11 +1161,11 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1457        /* open pipe to uncompress or decrypt spool file */
1458        if (flp->flags&F_COMPRESS) {
1459         if (str_eq(flp->compress,S_BZIP2))
1460 -         snprintf(MAXS(cmd),"%s -d < %s/%d.d",bzip2_bin,userspool,flp->id);
1461 +         snprintf(cmd,sizeof(cmd)-1,"%s -d < %s/%d.d",bzip2_bin,userspool,flp->id);
1462         else
1463 -         snprintf(MAXS(cmd),"%s -d < %s/%d.d",gzip_bin,userspool,flp->id);
1464 +         snprintf(cmd,sizeof(cmd)-1,"%s -d < %s/%d.d",gzip_bin,userspool,flp->id);
1465        } else if (flp->flags&F_CRYPT)
1466 -         snprintf(MAXS(cmd),
1467 +         snprintf(cmd,sizeof(cmd)-1,
1468                    "%s %s -f < %s/%d.d",pgp_bin,pgpvm,userspool,flp->id);
1469        if ((pp=vpopen(cmd,"r")) == NULL) {
1470          message(prg,'E',"cannot open spool file for reading");
1471 @@ -1176,7 +1176,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1472        if (!(outf=rfopen(fname,"w"))) {
1473         pclose(pp);
1474         printf("\n"); 
1475 -       snprintf(MAXS(tmp),"cannot open '%s' for writing",nname);
1476 +       snprintf(tmp,sizeof(tmp)-1,"cannot open '%s' for writing",nname);
1477          message(prg,'E',tmp);
1478          return;
1479        }
1480 @@ -1192,12 +1192,12 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1481  
1482      } else  /* binary format */ {
1483       
1484 -      snprintf(MAXS(sfile),"%s/%d.d",userspool,flp->id);
1485 +      snprintf(sfile,sizeof(sfile)-1,"%s/%d.d",userspool,flp->id);
1486  
1487        /* try to create destination file */
1488        /* open output file */
1489        if (!(outf=rfopen(fname,"w"))) {
1490 -        snprintf(MAXS(tmp),"cannot open '%s' for writing",nname);
1491 +        snprintf(tmp,sizeof(tmp)-1,"cannot open '%s' for writing",nname);
1492          message(prg,'E',tmp);
1493          return;
1494        }
1495 @@ -1215,16 +1215,16 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1496             *++cp=0;
1497           else
1498             *tmp=0;
1499 -         snprintf(MAXS(tmpfile),"%sreceive-%d.tmp",tmp,(int)getpid());
1500 -         snprintf(MAXS(tmp),"%s -d < %s > %s",bzip2_bin,sfile,tmpfile);
1501 +         snprintf(tmpfile,sizeof(tmpfile)-1,"%sreceive-%d.tmp",tmp,(int)getpid());
1502 +         snprintf(tmp,sizeof(tmp)-1,"%s -d < %s > %s",bzip2_bin,sfile,tmpfile);
1503           if (vsystem(tmp)) {
1504 -           snprintf(MAXS(tmp),"call to %s failed, cannot receive '%s'",
1505 +           snprintf(tmp,sizeof(tmp)-1,"call to %s failed, cannot receive '%s'",
1506                      bzip2_bin,nname);
1507             message(prg,'E',tmp); 
1508             return;
1509           }
1510           if (rename(tmpfile,fname)<0) {
1511 -           snprintf(MAXS(tmp),"cannot write to '%s'",nname);
1512 +           snprintf(tmp,sizeof(tmp)-1,"cannot write to '%s'",nname);
1513             message(prg,'E',tmp); 
1514             unlink(tmpfile);
1515             return;
1516 @@ -1239,7 +1239,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1517  
1518           if (spawn(sad,fname,cmask)<0) {
1519             errno=0;
1520 -           snprintf(MAXS(tmp),
1521 +           snprintf(tmp,sizeof(tmp)-1,
1522                      "call to %s failed, cannot receive '%s'",sad[0],nname);
1523             message(prg,'E',tmp); 
1524             return;
1525 @@ -1252,10 +1252,10 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1526        /* encrypted spool file? */
1527        if (flp->flags&F_CRYPT) {
1528         
1529 -       snprintf(MAXS(cmd),"%s %s -f < %s > '%s'",pgp_bin,pgpvm,sfile,fname);
1530 +       snprintf(cmd,sizeof(cmd)-1,"%s %s -f < %s > '%s'",pgp_bin,pgpvm,sfile,fname);
1531         if (vsystem(cmd)!=0) {
1532           errno=0;
1533 -         snprintf(MAXS(tmp),"cannot receive '%s', pgp failed",nname);
1534 +         snprintf(tmp,sizeof(tmp)-1,"cannot receive '%s', pgp failed",nname);
1535           message(prg,'E',tmp);
1536           unlink(fname);
1537           return;
1538 @@ -1274,7 +1274,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1539         !(flp->flags&F_CRYPT)) {
1540       
1541        /* open input file */
1542 -      snprintf(MAXS(sfile),"%s/%d.d",userspool,flp->id);
1543 +      snprintf(sfile,sizeof(sfile)-1,"%s/%d.d",userspool,flp->id);
1544        if ((inf=rfopen(sfile,"r")) == NULL) {
1545          message(prg,'E',"cannot open spool file for reading");
1546          return;
1547 @@ -1282,7 +1282,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1548  
1549        /* open output file */
1550        if ((outf=rfopen(fname,"w")) == NULL) {
1551 -        snprintf(MAXS(tmp),"cannot open '%s' for writing",nname);
1552 +        snprintf(tmp,sizeof(tmp)-1,"cannot open '%s' for writing",nname);
1553          message(prg,'E',tmp);
1554          fclose(inf);
1555          return;
1556 @@ -1298,9 +1298,9 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1557      } else   /* binary file */ {
1558       
1559        /* copy file */
1560 -      snprintf(MAXS(tmp),"%s/%d.d",userspool,flp->id);
1561 +      snprintf(tmp,sizeof(tmp)-1,"%s/%d.d",userspool,flp->id);
1562        if (fcopy(tmp,fname,0666&~cmask)<0) {
1563 -        snprintf(MAXS(tmp),"cannot receive '%s'",nname);
1564 +        snprintf(tmp,sizeof(tmp)-1,"cannot receive '%s'",nname);
1565         errno=0;
1566          message(prg,'E',tmp);
1567         return;
1568 @@ -1315,20 +1315,20 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1569    /* executable flag set? */
1570    if (flp->flags&F_EXE) chmod(fname,(S_IRWXU|S_IRWXG|S_IRWXO)&~cmask);
1571  
1572 -  snprintf(MAXS(tmp),"'%s' received",nname);
1573 +  snprintf(tmp,sizeof(tmp)-1,"'%s' received",nname);
1574    message(prg,'I',tmp);
1575  
1576    /* foreign character set in text file? */
1577    if ((flp->flags&F_TEXT) && !str_eq(flp->charset,CHARSET)) {
1578     
1579      /* call GNU recode */
1580 -    snprintf(MAXS(tmp),"%s:"CHARSET,flp->charset);
1581 +    snprintf(tmp,sizeof(tmp)-1,"%s:"CHARSET,flp->charset);
1582      sad[0]=recode_bin;
1583      sad[1]=tmp;
1584      sad[2]=fname;
1585      sad[3]=NULL;
1586      if (spawn(sad,NULL,cmask)<0) {
1587 -      snprintf(MAXS(tmp),
1588 +      snprintf(tmp,sizeof(tmp)-1,
1589                "call to %s failed, cannot translate character set in '%s'",
1590                recode_bin,nname);
1591        message(prg,'E',tmp);
1592 @@ -1348,7 +1348,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1593      
1594      /* metamail call allowed? */
1595      if (nometamail) {
1596 -      snprintf(MAXS(tmp),
1597 +      snprintf(tmp,sizeof(tmp)-1,
1598                "'%s' is a MIME file, you have to run it through metamail",
1599                nname);
1600        message(prg,'I',tmp);
1601 @@ -1360,7 +1360,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1602        sad[1]=fname;
1603        sad[2]=NULL;
1604        if (spawn(sad,NULL,cmask)<0) {
1605 -       snprintf(MAXS(tmp),
1606 +       snprintf(tmp,sizeof(tmp)-1,
1607                  "call to %s failed, keeping local file '%s'",
1608                  metamail_bin,nname);
1609         message(prg,'E',tmp);
1610 @@ -1403,7 +1403,7 @@ void crlf2lf(FILE *inf, FILE *outf, const char *fname, const char *nname) {
1611       
1612        /* write lf */
1613        if(fputc(c2,outf)==EOF) {
1614 -        snprintf(MAXS(tmp),"cannot write to %s",nname);
1615 +        snprintf(tmp,sizeof(tmp)-1,"cannot write to %s",nname);
1616          message(prg,'E',tmp);
1617          return;
1618        }
1619 @@ -1415,7 +1415,7 @@ void crlf2lf(FILE *inf, FILE *outf, const char *fname, const char *nname) {
1620       
1621        /* write char */
1622        if(fputc(c1,outf)==EOF) {
1623 -        snprintf(MAXS(tmp),"cannot write to %s",nname);
1624 +        snprintf(tmp,sizeof(tmp)-1,"cannot write to %s",nname);
1625          message(prg,'E',tmp);
1626          return;
1627        }
1628 @@ -1426,7 +1426,7 @@ void crlf2lf(FILE *inf, FILE *outf, const char *fname, const char *nname) {
1629  
1630    /* write last char */
1631    if(fputc(c1,outf)==EOF) {
1632 -    snprintf(MAXS(tmp),"cannot write to %s",nname);
1633 +    snprintf(tmp,sizeof(tmp)-1,"cannot write to %s",nname);
1634      message(prg,'E',tmp);
1635      return;
1636    }
1637 @@ -1607,8 +1607,8 @@ int create_sigfile(const char *sign, const char *fname, const char *nname,
1638    /* no pgp signature to save? */
1639    if (!*sign) return(0);
1640  
1641 -  snprintf(MAXS(sigfile),"%s.sig",fname);
1642 -  snprintf(MAXS(nsigfile),"%s.sig",nname);
1643 +  snprintf(sigfile,sizeof(sigfile)-1,"%s.sig",fname);
1644 +  snprintf(nsigfile,sizeof(nsigfile)-1,"%s.sig",nname);
1645  
1646    /* signature file does already exist? */
1647    while (stat(sigfile,&finfo)==0 && (*overwrite!='Y')) {
1648 @@ -1641,7 +1641,7 @@ int create_sigfile(const char *sign, const char *fname, const char *nname,
1649    /* safety fallback: try to delete an old file with the same name */
1650    unlink(fname);
1651    if (stat(sigfile,&finfo)==0) {
1652 -    snprintf(MAXS(tmp),"cannot create '%s' : "
1653 +    snprintf(tmp,sizeof(tmp)-1,"cannot create '%s' : "
1654              "file does already exist and is not deletable",sigfile);
1655      errno=0;
1656      message(prg,'E',tmp);
1657 @@ -1649,14 +1649,14 @@ int create_sigfile(const char *sign, const char *fname, const char *nname,
1658    }
1659  
1660    if (!(outf=rfopen(sigfile,"w"))) {
1661 -    snprintf(MAXS(tmp),"cannot create signature file '%s' ",nsigfile);
1662 +    snprintf(tmp,sizeof(tmp)-1,"cannot create signature file '%s' ",nsigfile);
1663      message(prg,'E',tmp);
1664      return(-1);
1665    }
1666  
1667    fprintf(outf,"%s",sign);
1668    fclose(outf);
1669 -  snprintf(MAXS(tmp),"signature file '%s' created",nsigfile);
1670 +  snprintf(tmp,sizeof(tmp)-1,"signature file '%s' created",nsigfile);
1671    message(prg,'I',tmp);
1672    return(0);
1673  
1674 @@ -1695,9 +1695,9 @@ int check_signature(struct filelist *flp, char *pgpring, int print) {
1675    if (str_eq(pgpring,".")) *pgpring=0;
1676    
1677    /* write signature file */
1678 -  snprintf(MAXS(sigfile),"%s/%d.d.sig",userspool,flp->id);
1679 +  snprintf(sigfile,sizeof(sigfile)-1,"%s/%d.d.sig",userspool,flp->id);
1680    if (!(outf=rfopen(sigfile,"w"))) {
1681 -    snprintf(MAXS(tmp),"cannot write signature file %s",sigfile);
1682 +    snprintf(tmp,sizeof(tmp)-1,"cannot write signature file %s",sigfile);
1683      message(prg,'E',tmp);
1684      return(-2);
1685    }
1686 @@ -1707,15 +1707,15 @@ int check_signature(struct filelist *flp, char *pgpring, int print) {
1687    /* build pgp options */
1688    if (*pgpring) {
1689      if (access(pgpring,R_OK)<0) {
1690 -      snprintf(MAXS(tmp),"cannot read pgp pub ring file %s",pgpring);
1691 +      snprintf(tmp,sizeof(tmp)-1,"cannot read pgp pub ring file %s",pgpring);
1692        message(prg,'F',tmp);
1693      }
1694 -    snprintf(MAXS(pgpopt),"+batchmode=on +language=en +pubring=%s",pgpring);
1695 +    snprintf(pgpopt,sizeof(pgpopt)-1,"+batchmode=on +language=en +pubring=%s",pgpring);
1696    } else
1697 -    snprintf(MAXS(pgpopt),"+batchmode=on +language=en");
1698 +    snprintf(pgpopt,sizeof(pgpopt)-1,"+batchmode=on +language=en");
1699    
1700    /* check signature file with pgp */
1701 -  snprintf(MAXS(tmp),"%s %s %s 2>/dev/null",pgp_bin,pgpopt,sigfile);
1702 +  snprintf(tmp,sizeof(tmp)-1,"%s %s %s 2>/dev/null",pgp_bin,pgpopt,sigfile);
1703    if (!(pp=vpopen(tmp,"r"))) {
1704      message(prg,'E',"cannot call pgp");
1705      unlink(sigfile);
1706 @@ -1789,7 +1789,7 @@ void renumber (struct senderlist *sls) {
1707    max = nextfree = 1;
1708    
1709    if (chdir(userspool)<0) {
1710 -    snprintf(MAXS(tmp),"cannot change to %s",userspool);
1711 +    snprintf(tmp,sizeof(tmp)-1,"cannot change to %s",userspool);
1712      message(prg,'F',tmp);
1713    }
1714  
1715 @@ -1816,20 +1816,20 @@ void renumber (struct senderlist *sls) {
1716      while (fscanf(lockf,"%d\n",&i)!=EOF) {
1717        if (i<min && i>lastused && i>nextfree) min=i;
1718      }
1719 -    snprintf(MAXS(ofile),"%d.h",min);
1720 +    snprintf(ofile,sizeof(ofile)-1,"%d.h",min);
1721      for (i=nextfree; i<min; i++) {
1722 -      snprintf(MAXS(nfile),"%d.h",i);
1723 +      snprintf(nfile,sizeof(nfile)-1,"%d.h",i);
1724        if (stat(nfile,&finfo)<0 || finfo.st_size==0) {
1725         unlink(nfile);
1726         if (rename(ofile,nfile)<0) {
1727 -         snprintf(MAXS(tmp),"cannot rename %s to %s",ofile,nfile);
1728 +         snprintf(tmp,sizeof(tmp)-1,"cannot rename %s to %s",ofile,nfile);
1729           message(prg,'F',tmp);
1730         }
1731 -       snprintf(MAXS(nfile),"%d.d",i);
1732 -       snprintf(MAXS(ofile),"%d.d",min);
1733 +       snprintf(nfile,sizeof(nfile)-1,"%d.d",i);
1734 +       snprintf(ofile,sizeof(ofile)-1,"%d.d",min);
1735         unlink(nfile);
1736         if (rename(ofile,nfile)<0) {
1737 -         snprintf(MAXS(tmp),"cannot rename %s to %s",ofile,nfile);
1738 +         snprintf(tmp,sizeof(tmp)-1,"cannot rename %s to %s",ofile,nfile);
1739           message(prg,'F',tmp);
1740         }
1741         nextfree=i+1;
1742 diff --git a/src/sendfile.c b/src/sendfile.c
1743 index 9f84393..09f9f52 100644
1744 --- a/src/sendfile.c
1745 +++ b/src/sendfile.c
1746 @@ -651,7 +651,7 @@ const char
1747      if (strstr(force_compress,"gzip"))  compress=S_GZIP;
1748      if (strstr(force_compress,"bzip2")) compress=S_BZIP2;
1749      if (!*compress) {
1750 -      snprintf(MAXS(tmp),"unsupported compression program %s",force_compress);
1751 +      snprintf(tmp,sizeof(tmp)-1,"unsupported compression program %s",force_compress);
1752        errno=0;
1753        message(prg,'F',tmp);
1754      }
1755 @@ -660,7 +660,7 @@ const char
1756    } else if (*compress) {
1757  
1758  #if 0
1759 -    snprintf(MAXS(tmp),"%s --help 2>&1",bzip2_bin);
1760 +    snprintf(tmp,sizeof(tmp)-1,"%s --help 2>&1",bzip2_bin);
1761      if ((pp=popen(tmp,"r"))) {
1762        while (fgetl(line,pp)) {
1763         if (strstr(line,"usage:")) {
1764 @@ -678,7 +678,7 @@ const char
1765      }
1766      if (!*zprg) *bzip2_bin=0;
1767         
1768 -    snprintf(MAXS(tmp),"%s --help 2>&1",gzip_bin);
1769 +    snprintf(tmp,sizeof(tmp)-1,"%s --help 2>&1",gzip_bin);
1770      if ((pp=popen(tmp,"r"))) {
1771        while (fgetl(line,pp)) if (strstr(line,"usage:")) break;
1772        pclose(pp);
1773 @@ -719,7 +719,7 @@ const char
1774    if (str_eq(host,"127.0.0.1") || str_eq(host,"0")) strcpy(host,localhost);
1775  
1776    if (*aopt) {
1777 -    snprintf(MAXS(cmd),"%s %s ",argv[0],aopt);
1778 +    snprintf(cmd,sizeof(cmd)-1,"%s %s ",argv[0],aopt);
1779      for(i=1;i<argc-1;i++) {
1780        strcat(cmd,"'");
1781        strcat(cmd,argv[i]);
1782 @@ -764,7 +764,7 @@ const char
1783           pgpcrypt='e';
1784           compress="";
1785           pop++;
1786 -         snprintf(MAXS(pgprid),"%s@%s",recipient,host);
1787 +         snprintf(pgprid,sizeof(pgprid)-1,"%s@%s",recipient,host);
1788  
1789           /* is there a recipient id? */
1790           if (*pop>'\n') {
1791 @@ -796,7 +796,7 @@ const char
1792           /* is there a signature id? */
1793           if (*pop>'\n') {
1794             if (*pop=='=') pop++;
1795 -           snprintf(MAXS(pgpsign),"-u '%s",pop);
1796 +           snprintf(pgpsign,sizeof(pgpsign)-1,"-u '%s",pop);
1797  
1798             /* cut off any more options */
1799             if ((cp=strchr(pgpsign,'\n'))) {
1800 @@ -813,7 +813,7 @@ const char
1801  
1802         /* wrong pgp options */
1803         errno=0;
1804 -       snprintf(MAXS(tmp),"wrong pgp option, see 'man %s'",prg);
1805 +       snprintf(tmp,sizeof(tmp)-1,"wrong pgp option, see 'man %s'",prg);
1806         message(prg,'F',tmp);
1807  
1808        }
1809 @@ -821,13 +821,13 @@ const char
1810    }
1811  
1812    /* set various file names */
1813 -  snprintf(MAXS(userspool),SPOOL"/%s",pw_name);
1814 -  snprintf(MAXS(outlogtmp),"%s/.sendfile_%d.log",userspool,pid);
1815 -  snprintf(MAXS(tartmp),"%s/sendfile.tar",tmpdir);
1816 -  snprintf(MAXS(ziptmp),"%s/sendfile.zip",tmpdir);
1817 -  snprintf(MAXS(pgptmp),"%s/sendfile.pgp",tmpdir);
1818 -  snprintf(MAXS(texttmp),"%s/sendfile.txt",tmpdir);
1819 -  snprintf(MAXS(stdintmp),"%s/sendfile.tmp",tmpdir);
1820 +  snprintf(userspool,sizeof(userspool)-1,SPOOL"/%s",pw_name);
1821 +  snprintf(outlogtmp,sizeof(outlogtmp)-1,"%s/.sendfile_%d.log",userspool,pid);
1822 +  snprintf(tartmp,sizeof(tartmp)-1,"%s/sendfile.tar",tmpdir);
1823 +  snprintf(ziptmp,sizeof(ziptmp)-1,"%s/sendfile.zip",tmpdir);
1824 +  snprintf(pgptmp,sizeof(pgptmp)-1,"%s/sendfile.pgp",tmpdir);
1825 +  snprintf(texttmp,sizeof(texttmp)-1,"%s/sendfile.txt",tmpdir);
1826 +  snprintf(stdintmp,sizeof(stdintmp)-1,"%s/sendfile.tmp",tmpdir);
1827  
1828    /* where are the files/directories ? */
1829    if (*where) {
1830 @@ -845,11 +845,11 @@ const char
1831        if (quiet)
1832         printf("%s\n",userspool);
1833        else {
1834 -       snprintf(MAXS(tmp),"the user spool directory is: %s",userspool);
1835 +       snprintf(tmp,sizeof(tmp)-1,"the user spool directory is: %s",userspool);
1836         message(prg,'I',tmp);
1837        } 
1838      } else {
1839 -      snprintf(MAXS(tmp),"%s is an unknown -W argument",where);
1840 +      snprintf(tmp,sizeof(tmp)-1,"%s is an unknown -W argument",where);
1841        errno=0;
1842        message(prg,'E',tmp);
1843        if (quiet<2) message(prg,'I',"you may specify -W=config, -W=spool, or "
1844 @@ -865,27 +865,27 @@ const char
1845    unlink(pgptmp);
1846    unlink(stdintmp);
1847    if (stat(tartmp,&finfo)==0) {
1848 -    snprintf(MAXS(tmp),
1849 +    snprintf(tmp,sizeof(tmp)-1,
1850              "tmp-file %s does already exist and cannot be deleted",tartmp);
1851      message(prg,'F',tmp);
1852    }
1853    if (stat(ziptmp,&finfo)==0) {
1854 -    snprintf(MAXS(tmp),
1855 +    snprintf(tmp,sizeof(tmp)-1,
1856              "tmp-file %s does already exist and cannot be deleted",ziptmp);
1857      message(prg,'F',tmp);
1858    }
1859    if (stat(texttmp,&finfo)==0) {
1860 -    snprintf(MAXS(tmp),
1861 +    snprintf(tmp,sizeof(tmp)-1,
1862              "tmp-file %s does already exist and cannot be deleted",texttmp);
1863      message(prg,'F',tmp);
1864    }
1865    if (stat(pgptmp,&finfo)==0) {
1866 -    snprintf(MAXS(tmp),
1867 +    snprintf(tmp,sizeof(tmp)-1,
1868              "tmp-file %s does already exist and cannot be deleted",pgptmp);
1869      message(prg,'F',tmp);
1870    }
1871    if (stat(stdintmp,&finfo)==0) {
1872 -    snprintf(MAXS(tmp),
1873 +    snprintf(tmp,sizeof(tmp)-1,
1874              "tmp-file %s does already exist and cannot be deleted",stdintmp);
1875      message(prg,'F',tmp);
1876    }
1877 @@ -954,7 +954,7 @@ const char
1878    /* set tcp packet length */
1879    if (packet_size<1) packet_size=PACKET;
1880    if (verbose && !spool && !del) {
1881 -    snprintf(MAXS(tmp),"packet size = %d bytes",packet_size);
1882 +    snprintf(tmp,sizeof(tmp)-1,"packet size = %d bytes",packet_size);
1883      message(prg,'I',tmp);
1884    }
1885  
1886 @@ -970,14 +970,14 @@ const char
1887     
1888      /* write stdin to tmp-file */
1889      if (!(outf=rfopen(stdintmp,"w"))) {
1890 -      snprintf(MAXS(tmp),"cannot open tmp-file %s",stdintmp);
1891 +      snprintf(tmp,sizeof(tmp)-1,"cannot open tmp-file %s",stdintmp);
1892        message(prg,'F',tmp);
1893      }
1894      /* while ((ch=getchar())!=EOF) putc(ch,outf); */
1895      while ((bytes=read(fileno(stdin),iobuf,IOB))) {
1896        if (bytes<0) message(prg,'F',"error while reading from stdin");
1897        if (write(fileno(outf),iobuf,bytes)!=bytes) {
1898 -       snprintf(MAXS(tmp),"error while writing stdin to %s",stdintmp);
1899 +       snprintf(tmp,sizeof(tmp)-1,"error while writing stdin to %s",stdintmp);
1900         message(prg,'F',tmp);
1901        }
1902      }
1903 @@ -1022,13 +1022,13 @@ const char
1904        /* does the outgoing spool exist? */
1905        strcpy(outgoing,SPOOL"/OUTGOING");
1906        if (stat(outgoing,&finfo)<0 || !S_ISDIR(finfo.st_mode)) {
1907 -       snprintf(MAXS(tmp),"spool directory %s does not exist",outgoing);
1908 +       snprintf(tmp,sizeof(tmp)-1,"spool directory %s does not exist",outgoing);
1909         message(prg,'F',tmp);
1910        }
1911  
1912        /* and does it have the correct protection? */
1913        if (!((finfo.st_mode&S_ISVTX) && (finfo.st_mode&S_IRWXO))) {
1914 -       snprintf(MAXS(tmp),
1915 +       snprintf(tmp,sizeof(tmp)-1,
1916                  "spool directory %s has wrong protection (must have 1777)",
1917                  outgoing);
1918         message(prg,'F',tmp);
1919 @@ -1045,19 +1045,19 @@ const char
1920  
1921      /* does the spool directory exist? */
1922      if (chdir(userspool)<0) {
1923 -      snprintf(MAXS(tmp),"cannot access spool directory %s",userspool);
1924 +      snprintf(tmp,sizeof(tmp)-1,"cannot access spool directory %s",userspool);
1925        message(prg,'F',tmp);
1926      }
1927  
1928      /* main loop over the spool file names */
1929      for (fn=optind; fn<argc-1; fn++) {
1930 -      snprintf(MAXS(sdfn),"%s.d",argv[fn]);
1931 -      snprintf(MAXS(shfn),"%s.h",argv[fn]);
1932 -      if (info) snprintf(MAXS(tinfo),"#%d/%d: ",fn-optind+1,argc-optind-1);
1933 +      snprintf(sdfn,sizeof(sdfn)-1,"%s.d",argv[fn]);
1934 +      snprintf(shfn,sizeof(shfn)-1,"%s.h",argv[fn]);
1935 +      if (info) snprintf(tinfo,sizeof(tinfo)-1,"#%d/%d: ",fn-optind+1,argc-optind-1);
1936        
1937        /* try to open spool header file */
1938        if (!(shf=rfopen(shfn,"r"))) {
1939 -        snprintf(MAXS(tmp),"cannot open spool file #%s",argv[fn]);
1940 +        snprintf(tmp,sizeof(tmp)-1,"cannot open spool file #%s",argv[fn]);
1941         message(prg,'E',tmp);
1942          continue;
1943        }
1944 @@ -1091,7 +1091,7 @@ const char
1945           strcpy(comment,strchr(line,' ')+1);
1946           if ((cp=strchr(comment,' '))) {
1947             *cp=0;
1948 -           snprintf(MAXS(tmp),"%s+ACA-(%s)",comment,cp+1);
1949 +           snprintf(tmp,sizeof(tmp)-1,"%s+ACA-(%s)",comment,cp+1);
1950             strcpy(comment,tmp);
1951           }
1952           continue;
1953 @@ -1129,7 +1129,7 @@ const char
1954             if (str_beq(reply,"200 ")) break;
1955             
1956             /* error! */
1957 -           snprintf(MAXS(tmp),"cannot send %s : %s",file,reply+4);
1958 +           snprintf(tmp,sizeof(tmp)-1,"cannot send %s : %s",file,reply+4);
1959             errno=0;
1960             message(prg,'E',tmp);
1961             fclose(inf);
1962 @@ -1142,15 +1142,15 @@ const char
1963             /* recompress spool file */
1964             if (str_eq(type,S_BZIP2)) {
1965               if (str_eq(compress,S_GZIP))
1966 -               snprintf(MAXS(cmd),"%s -d <%s|%s>%s",BZIP2,sdfn,GZIP,ziptmp);
1967 +               snprintf(cmd,sizeof(cmd)-1,"%s -d <%s|%s>%s",BZIP2,sdfn,GZIP,ziptmp);
1968               else
1969 -               snprintf(MAXS(cmd),"%s -d < %s > %s",BZIP2,sdfn,ziptmp);
1970 +               snprintf(cmd,sizeof(cmd)-1,"%s -d < %s > %s",BZIP2,sdfn,ziptmp);
1971             } else
1972 -             snprintf(MAXS(cmd),"%s -dc %s > %s",GZIP,sdfn,ziptmp);
1973 +             snprintf(cmd,sizeof(cmd)-1,"%s -dc %s > %s",GZIP,sdfn,ziptmp);
1974             
1975             /* execute shell-command and close spool header file on error */
1976             if (vsystem(cmd)) {
1977 -             snprintf(MAXS(tmp),"cannot recompress spool file #%s",argv[fn]);
1978 +             snprintf(tmp,sizeof(tmp)-1,"cannot recompress spool file #%s",argv[fn]);
1979               message(prg,'E',tmp);
1980               fclose(inf);
1981               break;
1982 @@ -1169,9 +1169,9 @@ const char
1983         /* is there already a comment line? */
1984         if (str_beq(line,"COMMENT")) {
1985           if (*redirect) 
1986 -           snprintf(MAXS(line),"%s+AA0ACg-%s",comment,redirect);
1987 +           snprintf(line,sizeof(line)-1,"%s+AA0ACg-%s",comment,redirect);
1988           else {
1989 -           snprintf(MAXS(tmp),
1990 +           snprintf(tmp,sizeof(tmp)-1,
1991                      "%s+AA0ACg-forward+ACA-from+ACA-%s",line,comment);
1992             strcpy(line,tmp);
1993           }
1994 @@ -1200,9 +1200,9 @@ const char
1995        /* send comment if not already done */
1996        if (*comment) {
1997          iso2utf(tmp,"forward from ");
1998 -       snprintf(MAXS(line),"COMMENT %s%s",tmp,comment);
1999 +       snprintf(line,sizeof(line)-1,"COMMENT %s%s",tmp,comment);
2000         if (*redirect) {
2001 -         snprintf(MAXS(tmp),"\r\n%s",redirect);
2002 +         snprintf(tmp,sizeof(tmp)-1,"\r\n%s",redirect);
2003           iso2utf(comment,tmp);
2004           strcat(line,comment);
2005         }
2006 @@ -1215,12 +1215,12 @@ const char
2007        /* check the file size */
2008        if (stat(ziptmp,&finfo)==0) {
2009         size=finfo.st_size;
2010 -       snprintf(MAXS(sizes),"%lld %lld",size,orgsize);
2011 -       snprintf(MAXS(line),"SIZE %s",sizes);
2012 +       snprintf(sizes,sizeof(sizes)-1,"%lld %lld",size,orgsize);
2013 +       snprintf(line,sizeof(line)-1,"SIZE %s",sizes);
2014         sendcommand(sockfd,line,NULL);
2015        } else {
2016         if (stat(sdfn,&finfo)<0 || size!=finfo.st_size) {
2017 -         snprintf(MAXS(tmp),
2018 +         snprintf(tmp,sizeof(tmp)-1,
2019                    "spool file #%s has wrong size count - ignored",argv[fn]);
2020           errno=0;
2021           message(prg,'E',tmp);
2022 @@ -1302,7 +1302,7 @@ const char
2023        fflush(stdout);
2024      }
2025      if (verbose) {
2026 -      snprintf(MAXS(tmp),"shell-call: %s",cmd);
2027 +      snprintf(tmp,sizeof(tmp)-1,"shell-call: %s",cmd);
2028        message(prg,'I',tmp);
2029      }
2030  
2031 @@ -1331,9 +1331,9 @@ const char
2032        /* compress tar-archive */
2033        if (!quiet) printf("compressing...       \r");
2034        fflush(stdout);
2035 -      snprintf(MAXS(cmd),"%s < %s > %s",zprg,tartmp,ziptmp);
2036 +      snprintf(cmd,sizeof(cmd)-1,"%s < %s > %s",zprg,tartmp,ziptmp);
2037        if (verbose) {
2038 -       snprintf(MAXS(tmp),"shell-call: %s",cmd);
2039 +       snprintf(tmp,sizeof(tmp)-1,"shell-call: %s",cmd);
2040         message(prg,'I',tmp);
2041        }
2042        if (vsystem(cmd)) message(prg,'F',"cannot compress archive file");
2043 @@ -1350,7 +1350,7 @@ const char
2044      /* get the file size */
2045      if (stat(file,&finfo)<0) message(prg,'F',"cannot access tmp file");
2046      size=finfo.st_size;
2047 -    snprintf(MAXS(sizes),"%lld %lld",size,orgsize);
2048 +    snprintf(sizes,sizeof(sizes)-1,"%lld %lld",size,orgsize);
2049  
2050      /* write to outgoing spool? */
2051      if (spool) {
2052 @@ -1360,9 +1360,9 @@ const char
2053          
2054         /* create correct to-string */
2055         if (strchr(argv[argc-1],'*'))
2056 -         snprintf(MAXS(to),"%s",argv[argc-1]);
2057 +         snprintf(to,sizeof(to)-1,"%s",argv[argc-1]);
2058         else
2059 -         snprintf(MAXS(to),"%s@%s",recipient,host);
2060 +         snprintf(to,sizeof(to)-1,"%s@%s",recipient,host);
2061           
2062         /* search for file in outgoing spool */
2063         for (hlp=hls; hlp; hlp=hlp->next) {
2064 @@ -1372,7 +1372,7 @@ const char
2065             if (simplematch(oflp->fname,utf_name,0)) {
2066                 
2067               /* matching recipient? */
2068 -             snprintf(MAXS(rto),"%s@%s",oflp->to,hlp->host);
2069 +             snprintf(rto,sizeof(rto)-1,"%s@%s",oflp->to,hlp->host);
2070               if (simplematch(rto,to,0)) {
2071                 unlink(oflp->oshfn);
2072                 oflp->oshfn[strlen(oflp->oshfn)-1]='d';
2073 @@ -1406,7 +1406,7 @@ const char
2074        
2075      } else { /* send header lines */
2076  
2077 -      snprintf(MAXS(tmp),"FILE %s",utf_name);
2078 +      snprintf(tmp,sizeof(tmp)-1,"FILE %s",utf_name);
2079        /* deactivate exit on 4xx error to test for timeout */
2080        client=0;
2081        sendcommand(sockfd,tmp,reply);
2082 @@ -1415,7 +1415,7 @@ const char
2083        /* saft server still online? (check timeout) */
2084        if (str_beq(reply,"429 ")) {
2085         sockfd=saft_connect("file",recipient,user,host,redirect);
2086 -       snprintf(MAXS(tmp),"FILE %s",utf_name);
2087 +       snprintf(tmp,sizeof(tmp)-1,"FILE %s",utf_name);
2088         sendcommand(sockfd,tmp,reply);
2089        }
2090        
2091 @@ -1424,14 +1424,14 @@ const char
2092        
2093        if (overwrite) {
2094         if (str_beq(reply,"200 ")) sendcommand(sockfd,"DEL",reply);
2095 -       snprintf(MAXS(tmp),"FILE %s",utf_name);
2096 +       snprintf(tmp,sizeof(tmp)-1,"FILE %s",utf_name);
2097         sendcommand(sockfd,tmp,reply);
2098        }
2099        if (*compress) {
2100         if (str_eq(compress,S_GZIP))
2101 -         snprintf(MAXS(tmp),"TYPE BINARY COMPRESSED");
2102 +         snprintf(tmp,sizeof(tmp)-1,"TYPE BINARY COMPRESSED");
2103         else
2104 -         snprintf(MAXS(tmp),"TYPE BINARY COMPRESSED=%s",compress);
2105 +         snprintf(tmp,sizeof(tmp)-1,"TYPE BINARY COMPRESSED=%s",compress);
2106         sendcommand(sockfd,tmp,reply);
2107         if (!test && !str_beq(reply,"200 ") && quiet<2) {
2108           errno=0;
2109 @@ -1448,7 +1448,7 @@ const char
2110         if (!test && !str_beq(reply,"200 ") && quiet<2) 
2111           message(prg,'W',"remote site does not support binary files");
2112        }
2113 -      snprintf(MAXS(tmp),"SIZE %s",sizes);
2114 +      snprintf(tmp,sizeof(tmp)-1,"SIZE %s",sizes);
2115        sendheader(sockfd,tmp);
2116        sendcommand(sockfd,"ATTR TAR",reply);
2117        if (!test && !str_beq(reply,"200 ") && quiet<2) {
2118 @@ -1463,7 +1463,7 @@ const char
2119        if (*comment) strcat(line,comment);
2120        if (*redirect) {
2121          if (*line) {
2122 -         snprintf(MAXS(tmp),"%s\r\n%s",line,redirect);
2123 +         snprintf(tmp,sizeof(tmp)-1,"%s\r\n%s",line,redirect);
2124           strcpy(line,tmp);
2125         } else
2126           strcpy(line,redirect);
2127 @@ -1472,7 +1472,7 @@ const char
2128        if (spool)
2129         fprintf(oshf,"COMMENT\t%s\n",tmp);
2130        else {
2131 -        snprintf(MAXS(line),"COMMENT %s",tmp);
2132 +        snprintf(line,sizeof(line)-1,"COMMENT %s",tmp);
2133         sendcommand(sockfd,line,NULL);
2134        }
2135      }
2136 @@ -1515,7 +1515,7 @@ const char
2137     
2138      /* main loop over the file names */
2139      for (fn=optind; fn<argc-1; fn++) {
2140 -      if (info) snprintf(MAXS(tinfo),"#%d/%d: ",fn-optind+1,argc-optind-1);
2141 +      if (info) snprintf(tinfo,sizeof(tinfo)-1,"#%d/%d: ",fn-optind+1,argc-optind-1);
2142       
2143        /* file from stdin? */
2144        if (stdinf) {
2145 @@ -1549,9 +1549,9 @@ const char
2146          
2147           /* create correct to-string */
2148           if (strchr(argv[argc-1],'*'))
2149 -           snprintf(MAXS(to),"%s",argv[argc-1]);
2150 +           snprintf(to,sizeof(to)-1,"%s",argv[argc-1]);
2151           else
2152 -           snprintf(MAXS(to),"%s@%s",recipient,host);
2153 +           snprintf(to,sizeof(to)-1,"%s@%s",recipient,host);
2154           
2155           /* search for file in outgoing spool */
2156           for (hlp=hls; hlp; hlp=hlp->next) {
2157 @@ -1561,7 +1561,7 @@ const char
2158               if (simplematch(oflp->fname,utf_name,0)) {
2159                 
2160                 /* matching recipient? */
2161 -               snprintf(MAXS(rto),"%s@%s",oflp->to,hlp->host);
2162 +               snprintf(rto,sizeof(rto)-1,"%s@%s",oflp->to,hlp->host);
2163                 if (simplematch(rto,to,0)) {
2164                   unlink(oflp->oshfn);
2165                   oflp->oshfn[strlen(oflp->oshfn)-1]='d';
2166 @@ -1569,7 +1569,7 @@ const char
2167                   if (del) {
2168                     del=2;
2169                     utf2iso(0,NULL,file,NULL,oflp->fname);
2170 -                   snprintf(MAXS(tmp),
2171 +                   snprintf(tmp,sizeof(tmp)-1,
2172                              "deleted from outgoing spool: '%s' for %s ",
2173                              file,rto);
2174                     if (quiet<2) message(prg,'I',tmp);
2175 @@ -1595,7 +1595,7 @@ const char
2176        } else /* send header lines */ {
2177         
2178         /* send file name */
2179 -       snprintf(MAXS(tmp),"FILE %s",utf_name);
2180 +       snprintf(tmp,sizeof(tmp)-1,"FILE %s",utf_name);
2181         sendcommand(sockfd,tmp,reply);
2182         if (!test && !str_beq(reply,"200 ") && quiet<2) 
2183           message(prg,'W',"remote site does not support file names");
2184 @@ -1606,7 +1606,7 @@ const char
2185           if (sendheader(sockfd,"DEL")) {
2186             if (quiet<2) message(prg,'W',"remote site cannot delete files");
2187           } else {
2188 -           snprintf(MAXS(tmp),"'%s' deleted",iso_name);
2189 +           snprintf(tmp,sizeof(tmp)-1,"'%s' deleted",iso_name);
2190             if (quiet<2) message(prg,'I',tmp);
2191           }
2192           continue;
2193 @@ -1616,7 +1616,7 @@ const char
2194  
2195        /* is the file readable? */
2196        if (stat(file,&finfo)<0) {
2197 -        snprintf(MAXS(tmp),"cannot access '%s'",file);
2198 +        snprintf(tmp,sizeof(tmp)-1,"cannot access '%s'",file);
2199         message(prg,'E',tmp);
2200         if (spool) {
2201           fclose(oshf);
2202 @@ -1628,7 +1628,7 @@ const char
2203        /* is it a regular file? */
2204        if (!S_ISREG(finfo.st_mode)) {
2205         errno=0;
2206 -        snprintf(MAXS(tmp),"%s is not a regular file, skipping",file);
2207 +        snprintf(tmp,sizeof(tmp)-1,"%s is not a regular file, skipping",file);
2208         message(prg,'E',tmp);
2209         if (spool) {
2210           fclose(oshf);
2211 @@ -1659,7 +1659,7 @@ const char
2212         inf=rfopen(file,"r");
2213         outf=rfopen(texttmp,"w");
2214         if (!inf) {
2215 -         snprintf(MAXS(tmp),"cannot open '%s'",file);
2216 +         snprintf(tmp,sizeof(tmp)-1,"cannot open '%s'",file);
2217           message(prg,'E',tmp);
2218           if (spool) {
2219             fclose(oshf);
2220 @@ -1703,7 +1703,7 @@ const char
2221         for (n=0;do_compress && *cft[n];n++) {
2222  
2223           /* is this file a not compressible one? */
2224 -         snprintf(MAXS(tmp),"*%s*",cft[n]);
2225 +         snprintf(tmp,sizeof(tmp)-1,"*%s*",cft[n]);
2226           if (simplematch(ftype,tmp,1)) do_compress=0;
2227  
2228         }
2229 @@ -1715,13 +1715,13 @@ const char
2230         /* compress tmp-file */
2231         if (!quiet) printf("compressing...       \r");
2232         fflush(stdout);
2233 -       snprintf(MAXS(cmd),"%s < '%s' > %s",zprg,file,ziptmp);
2234 +       snprintf(cmd,sizeof(cmd)-1,"%s < '%s' > %s",zprg,file,ziptmp);
2235         if (verbose) {
2236 -         snprintf(MAXS(tmp),"shell-call: %s",strchr(cmd,';')+1);
2237 +         snprintf(tmp,sizeof(tmp)-1,"shell-call: %s",strchr(cmd,';')+1);
2238           message(prg,'I',tmp);
2239         }
2240         if (vsystem(cmd)) {
2241 -         snprintf(MAXS(tmp),"cannot compress %s",file);
2242 +         snprintf(tmp,sizeof(tmp)-1,"cannot compress %s",file);
2243           message(prg,'E',tmp);
2244           if (spool) {
2245             fclose(oshf);
2246 @@ -1743,7 +1743,7 @@ const char
2247        /* get the file size */
2248        if (stat(file,&finfo)<0) message(prg,'F',"cannot access tmp file");
2249        size=finfo.st_size;
2250 -      snprintf(MAXS(sizes),"%lld %lld",size,orgsize);
2251 +      snprintf(sizes,sizeof(sizes)-1,"%lld %lld",size,orgsize);
2252        /*
2253          printf("DEBUG: size=%lld orgsize=%lld sizes=%s\n",size,orgsize,sizes); 
2254          exit(0);
2255 @@ -1781,22 +1781,22 @@ const char
2256         
2257         if (do_compress) {
2258           if (str_eq(compress,S_GZIP))
2259 -           snprintf(MAXS(line),"TYPE %s COMPRESSED",type);
2260 +           snprintf(line,sizeof(line)-1,"TYPE %s COMPRESSED",type);
2261           else
2262 -           snprintf(MAXS(line),"TYPE %s COMPRESSED=%s",type,compress);
2263 +           snprintf(line,sizeof(line)-1,"TYPE %s COMPRESSED=%s",type,compress);
2264         } else if (pgpcrypt)
2265 -         snprintf(MAXS(line),"TYPE %s CRYPTED",type);
2266 +         snprintf(line,sizeof(line)-1,"TYPE %s CRYPTED",type);
2267         else
2268 -         snprintf(MAXS(line),"TYPE %s",type);
2269 +         snprintf(line,sizeof(line)-1,"TYPE %s",type);
2270         sendcommand(sockfd,line,reply);
2271         if (!test && !str_beq(reply,"200 ") && quiet<2) {
2272           errno=0;
2273 -         snprintf(MAXS(tmp),"remote site does not support file of %s",line);
2274 +         snprintf(tmp,sizeof(tmp)-1,"remote site does not support file of %s",line);
2275           message(prg,'F',tmp);
2276         }
2277 -       snprintf(MAXS(tmp),"SIZE %s",sizes);
2278 +       snprintf(tmp,sizeof(tmp)-1,"SIZE %s",sizes);
2279         sendheader(sockfd,tmp);
2280 -       snprintf(MAXS(tmp),"DATE %s",date);
2281 +       snprintf(tmp,sizeof(tmp)-1,"DATE %s",date);
2282         if (sendheader(sockfd,tmp) && quiet<2)
2283           message(prg,'W',"remote site does not support dates");
2284         if (exe)
2285 @@ -1811,7 +1811,7 @@ const char
2286         if (*comment) strcat(line,comment);
2287         if (*redirect) {
2288           if (*line) {
2289 -           snprintf(MAXS(tmp),"%s\r\n%s",line,redirect);
2290 +           snprintf(tmp,sizeof(tmp)-1,"%s\r\n%s",line,redirect);
2291             strcpy(line,tmp);
2292           } else
2293             strcpy(line,redirect);
2294 @@ -1820,7 +1820,7 @@ const char
2295         if (spool)
2296           fprintf(oshf,"COMMENT\t%s\n",tmp);
2297         else {
2298 -         snprintf(MAXS(line),"COMMENT %s",tmp);
2299 +         snprintf(line,sizeof(line)-1,"COMMENT %s",tmp);
2300           sendcommand(sockfd,line,NULL);
2301         }
2302        }
2303 @@ -1880,15 +1880,15 @@ const char
2304    if (tsize && info && tfn>1 && quiet<2) {
2305      thruput=tsize*1000/tttime;
2306     if (tsize/1024>9999)
2307 -      snprintf(MAXS(tmp),"%d files sent with %.1f MB",tfn,tsize/1024/1024);
2308 +      snprintf(tmp,sizeof(tmp)-1,"%d files sent with %.1f MB",tfn,tsize/1024/1024);
2309      else if (tsize>9999)
2310 -      snprintf(MAXS(tmp),"%d files sent with %.1f kB",tfn,tsize/1024);
2311 +      snprintf(tmp,sizeof(tmp)-1,"%d files sent with %.1f kB",tfn,tsize/1024);
2312      else
2313 -      snprintf(MAXS(tmp),"%d files sent with %d byte",tfn,(int)tsize);
2314 +      snprintf(tmp,sizeof(tmp)-1,"%d files sent with %d byte",tfn,(int)tsize);
2315      if (thruput>9999)
2316 -      snprintf(MAXS(line),"%s at %.1f kB/s",tmp,thruput/1024);
2317 +      snprintf(line,sizeof(line)-1,"%s at %.1f kB/s",tmp,thruput/1024);
2318      else
2319 -      snprintf(MAXS(line),"%s at %d byte/s",tmp,(int)thruput);
2320 +      snprintf(line,sizeof(line)-1,"%s at %d byte/s",tmp,(int)thruput);
2321      message("",'I',line);
2322    }
2323  
2324 @@ -1952,7 +1952,7 @@ void cleanup() {
2325        if (str_beq(reply,"220 ") && strstr(reply,"SAFT")) {
2326         
2327         /* send LOG command */
2328 -       snprintf(MAXS(line),"LOG %s %s",pw_name,outlogtmp);
2329 +       snprintf(line,sizeof(line)-1,"LOG %s %s",pw_name,outlogtmp);
2330         sock_putline(sockfd,line);
2331         sock_getline(sockfd,reply);
2332         str_trim(reply);
2333 @@ -1981,7 +1981,7 @@ void cleanup() {
2334             if (str_beq(reply,"220 ") && strstr(reply,"SAFT")) {
2335               
2336               /* send LOG command */
2337 -             snprintf(MAXS(line),"LOG %s %s",pw_name,outlogtmp);
2338 +             snprintf(line,sizeof(line)-1,"LOG %s %s",pw_name,outlogtmp);
2339               sock_putline(sockfd,line);
2340               sock_getline(sockfd,reply);
2341               str_trim(reply);
2342 @@ -2033,7 +2033,7 @@ void pgp_encrypt(int pgpcrypt, char *pgprid, char *file) {
2343  
2344    /* look for matching pgp-IDs */
2345    if (strlen(pgprid)>1) {
2346 -    snprintf(MAXS(cmd),"%s -kvf %s > %s 2>/dev/null",pgp_bin,pgprid,pgptmp);
2347 +    snprintf(cmd,sizeof(cmd)-1,"%s -kvf %s > %s 2>/dev/null",pgp_bin,pgprid,pgptmp);
2348      vsystem(cmd);
2349      if (stat(pgptmp,&finfo)<0 || finfo.st_size==0 || !(inf=rfopen(pgptmp,"r"))) {
2350        errno=0;
2351 @@ -2044,7 +2044,7 @@ void pgp_encrypt(int pgpcrypt, char *pgprid, char *file) {
2352      if ((cp=strchr(line,'.'))) *cp=0;
2353      if (!str_eq(line,"1 matching key found")) {
2354        if (!quiet) {
2355 -       snprintf(MAXS(line),"ambigous pgp-ID '%s'",pgprid);
2356 +       snprintf(line,sizeof(line)-1,"ambigous pgp-ID '%s'",pgprid);
2357         message(prg,'W',line);
2358         inf=rfopen(pgptmp,"r");
2359         while (fgetl(line,inf)) printf("%s",line);
2360 @@ -2057,7 +2057,7 @@ void pgp_encrypt(int pgpcrypt, char *pgprid, char *file) {
2361  
2362    /* pgp needs user input? */
2363    if (pgpcrypt=='c' || !*pgprid) {
2364 -    snprintf(MAXS(cmd),"%s +armor=off -f%c < %s > %s",
2365 +    snprintf(cmd,sizeof(cmd)-1,"%s +armor=off -f%c < %s > %s",
2366              pgp_bin,pgpcrypt,shell_quote(file),pgptmp);
2367      if (vsystem(cmd) || stat(pgptmp,&finfo)<0 || finfo.st_size==0) {
2368        errno=0;
2369 @@ -2067,7 +2067,7 @@ void pgp_encrypt(int pgpcrypt, char *pgprid, char *file) {
2370  
2371    /* pgp needs no user input */ 
2372    } else {
2373 -    snprintf(MAXS(cmd),"%s +armor=off -fe %s < %s > %s 2>/dev/null",
2374 +    snprintf(cmd,sizeof(cmd)-1,"%s +armor=off -fe %s < %s > %s 2>/dev/null",
2375              pgp_bin,pgprid,shell_quote(file),pgptmp);
2376      if (vsystem(cmd) || stat(pgptmp,&finfo)<0 || finfo.st_size==0) {
2377        errno=0;
2378 @@ -2102,10 +2102,10 @@ void pgp_sign(const char *pgpsign, const char *infile, int sockfd) {
2379  
2380    if (!quiet && !pgppass) message(prg,'I',"call to pgp...");
2381  
2382 -  snprintf(MAXS(cmd),"%s %s -fsba %s < %s",
2383 +  snprintf(cmd,sizeof(cmd)-1,"%s %s -fsba %s < %s",
2384            pgp_bin,pgpvm,pgpsign,shell_quote(infile));
2385    if (verbose) {
2386 -    snprintf(MAXS(tmp),"shell-call: %s",cmd);
2387 +    snprintf(tmp,sizeof(tmp)-1,"shell-call: %s",cmd);
2388      message(prg,'I',tmp);
2389    }
2390    if (!(pipe=popen(cmd,"r"))) message(prg,'F',"call to pgp (signature) failed");
2391 @@ -2124,7 +2124,7 @@ void pgp_sign(const char *pgpsign, const char *infile, int sockfd) {
2392    if (check!=3) message(prg,'F',"call to pgp (signature) failed");
2393  
2394    iso2utf(tmp,sign);
2395 -  snprintf(MAXS(sign),"SIGN %s",tmp);
2396 +  snprintf(sign,sizeof(sign)-1,"SIGN %s",tmp);
2397    if (sockfd) sendcommand(sockfd,sign,NULL);
2398  }
2399  
2400 @@ -2197,13 +2197,13 @@ void start_spooldaemon(char *localhost) {
2401  #else
2402    sockfd=open_connection(localhost,SERVICE);
2403  #endif
2404 -  if (sockfd==-1) snprintf(MAXS(tmp),"cannot create a network socket "
2405 +  if (sockfd==-1) snprintf(tmp,sizeof(tmp)-1,"cannot create a network socket "
2406                               "- cannot start local spool daemon");
2407 -  if (sockfd==-2) snprintf(MAXS(tmp),"cannot open connection to %s "
2408 +  if (sockfd==-2) snprintf(tmp,sizeof(tmp)-1,"cannot open connection to %s "
2409                               "- cannot start local spool daemon",localhost);
2410 -  if (sockfd==-3) snprintf(MAXS(tmp),"%s is unknown (name server down?) "
2411 +  if (sockfd==-3) snprintf(tmp,sizeof(tmp)-1,"%s is unknown (name server down?) "
2412                               "- cannot start local spool daemon",localhost);
2413 -  if (sockfd==-4) snprintf(MAXS(tmp),"out of memory "
2414 +  if (sockfd==-4) snprintf(tmp,sizeof(tmp)-1,"out of memory "
2415                               "- cannot start local spool daemon");
2416    if (sockfd<0) {
2417      errno=0;
2418 @@ -2215,10 +2215,10 @@ void start_spooldaemon(char *localhost) {
2419    if (!str_beq(line,"220 ") || !strstr(line,"SAFT")) {
2420      errno=0;
2421  #ifndef ENABLE_MULTIPROTOCOL
2422 -    snprintf(MAXS(tmp),"No SAFT server on port %d at %s "
2423 +    snprintf(tmp,sizeof(tmp)-1,"No SAFT server on port %d at %s "
2424                 "- cannot start local spool daemon",SAFT,localhost);
2425  #else
2426 -    snprintf(MAXS(tmp),"No SAFT server on port %s at %s "
2427 +    snprintf(tmp,sizeof(tmp)-1,"No SAFT server on port %s at %s "
2428                 "- cannot start local spool daemon",SERVICE,localhost);
2429  #endif
2430      message(prg,'F',tmp);
2431 @@ -2241,13 +2241,13 @@ void start_spooldaemon(char *localhost) {
2432  #else
2433      sockfd=open_connection(host,SERVICE);
2434  #endif
2435 -    if (sockfd==-1) snprintf(MAXS(tmp),"cannot create a network socket "
2436 +    if (sockfd==-1) snprintf(tmp,sizeof(tmp)-1,"cannot create a network socket "
2437                                 "- cannot start local spool daemon");
2438 -    if (sockfd==-2) snprintf(MAXS(tmp),"cannot open connection to %s "
2439 +    if (sockfd==-2) snprintf(tmp,sizeof(tmp)-1,"cannot open connection to %s "
2440                                 "- cannot start local spool daemon",host);
2441 -    if (sockfd==-3) snprintf(MAXS(tmp),"%s is unknown (name server down?) "
2442 +    if (sockfd==-3) snprintf(tmp,sizeof(tmp)-1,"%s is unknown (name server down?) "
2443                                 "- cannot start local spool daemon",host);
2444 -    if (sockfd==-4) snprintf(MAXS(tmp),"out of memory "
2445 +    if (sockfd==-4) snprintf(tmp,sizeof(tmp)-1,"out of memory "
2446                                 "- cannot start local spool daemon");
2447      if (sockfd<0) {
2448        errno=0;
2449 @@ -2259,10 +2259,10 @@ void start_spooldaemon(char *localhost) {
2450      if (!str_beq(line,"220 ") || !strstr(line,"SAFT")) {
2451        errno=0;
2452  #ifndef ENABLE_MULTIPROTOCOL
2453 -      snprintf(MAXS(tmp),"No SAFT server on port %d at %s "
2454 +      snprintf(tmp,sizeof(tmp)-1,"No SAFT server on port %d at %s "
2455                   "- cannot start local spool daemon",SAFT,host);
2456  #else
2457 -      snprintf(MAXS(tmp),"No SAFT server on port %s at %s "
2458 +      snprintf(tmp,sizeof(tmp)-1,"No SAFT server on port %s at %s "
2459                   "- cannot start local spool daemon",SERVICE,host);
2460  #endif
2461        message(prg,'F',tmp);
2462 @@ -2392,7 +2392,7 @@ void get_header(const char *cmd, char *arg){
2463    if (!str_eq(cmd,line)) {
2464      errno=0;
2465      line[MAXLEN-80]=0;
2466 -    snprintf(MAXS(tmp),
2467 +    snprintf(tmp,sizeof(tmp)-1,
2468              "illegal SAFT command \"%s\", \"%s\" was expected",line,cmd);
2469      message(prg,'F',tmp);
2470    }
2471 @@ -2473,7 +2473,7 @@ char guess_ftype(const char *file, char *type) {
2472    /* next, try with file command */
2473    
2474    /* read output from file command */
2475 -  snprintf(MAXS(cmd),"file %s",shell_quote(file));
2476 +  snprintf(cmd,sizeof(cmd)-1,"file %s",shell_quote(file));
2477    if ((pipe=vpopen(cmd,"r")) && fgetl(tmp,pipe)) {
2478      pclose(pipe);
2479      
2480 @@ -2485,7 +2485,7 @@ char guess_ftype(const char *file, char *type) {
2481      if ((cp=strchr(type,'\n'))) *cp=0;
2482      
2483      if (verbose) {
2484 -      snprintf(MAXS(tmp),"%s is of type %s",file,type);
2485 +      snprintf(tmp,sizeof(tmp)-1,"%s is of type %s",file,type);
2486        message(prg,'I',tmp);
2487      }
2488      
2489 @@ -2535,14 +2535,14 @@ int linkspeed(const char *host, int lanspeed, char **compress) {
2490    if (lanspeed<1) return(1);
2491    
2492    /* create speeds dir if necessary */
2493 -  snprintf(MAXS(speeddir),"%s/speeds",userspool);
2494 +  snprintf(speeddir,sizeof(speeddir)-1,"%s/speeds",userspool);
2495    if (stat(speeddir,&finfo)<0 || !S_ISDIR(finfo.st_mode)) {
2496      unlink(speeddir);
2497      if (mkdir(speeddir,S_IRUSR|S_IWUSR|S_IXUSR)<0) return(1);
2498      chmod(speeddir,S_IRUSR|S_IWUSR|S_IXUSR);
2499    }
2500    
2501 -  snprintf(MAXS(hostfile),"%s/%s",speeddir,host);
2502 +  snprintf(hostfile,sizeof(hostfile)-1,"%s/%s",speeddir,host);
2503  
2504    /* if host file is missing return slow link */
2505    if (!(inf=rfopen(hostfile,"r"))) return(1);
2506 @@ -2552,11 +2552,11 @@ int linkspeed(const char *host, int lanspeed, char **compress) {
2507    if (speed<lanspeed) return(1);
2508  
2509    if (verbose) {
2510 -    snprintf(MAXS(msg),
2511 +    snprintf(msg,sizeof(msg)-1,
2512              "disabling compressing because last link speed to %s was %d kB/s",
2513              host,speed);
2514      message(prg,'I',msg);
2515 -    snprintf(MAXS(msg),"LAN speed is defined as min %d kB/s",lanspeed);
2516 +    snprintf(msg,sizeof(msg)-1,"LAN speed is defined as min %d kB/s",lanspeed);
2517      message(prg,'I',msg);
2518    }
2519  
2520 @@ -2587,14 +2587,14 @@ void notespeed(const char *host, unsigned long size, float ttime) {
2521    if (ttime<1 || size<102400) return;
2522      
2523    /* create speeds dir if necessary */
2524 -  snprintf(MAXS(speeddir),"%s/speeds",userspool);
2525 +  snprintf(speeddir,sizeof(speeddir)-1,"%s/speeds",userspool);
2526    if (stat(speeddir,&finfo)<0 || !S_ISDIR(finfo.st_mode)) {
2527      unlink(speeddir);
2528      if (mkdir(speeddir,S_IRUSR|S_IWUSR|S_IXUSR)<0) return;
2529      chmod(speeddir,S_IRUSR|S_IWUSR|S_IXUSR);
2530    }
2531    
2532 -  snprintf(MAXS(hostfile),"%s/%s",speeddir,host);
2533 +  snprintf(hostfile,sizeof(hostfile)-1,"%s/%s",speeddir,host);
2534  
2535    if ((outf=rfopen(hostfile,"w"))) {
2536      fprintf(outf,"%d\n",(int)(size/ttime/1.024)); /* kB/s */
2537 @@ -2658,7 +2658,7 @@ void spooled_info(const char *file, const char *sdf, int compressed) {
2538    if (quiet>1) return;
2539    
2540    if (stat(sdf,&finfo)<0) {
2541 -    snprintf(MAXS(tmp),"cannot access spool file %s",sdf);
2542 +    snprintf(tmp,sizeof(tmp)-1,"cannot access spool file %s",sdf);
2543      message(prg,'E',tmp);
2544      return;
2545    }
2546 @@ -2666,9 +2666,9 @@ void spooled_info(const char *file, const char *sdf, int compressed) {
2547    size=(finfo.st_size+512)/1024; 
2548    
2549    if (compressed)
2550 -    snprintf(MAXS(tmp),"'%s' spooled (%d KB [compressed])",file,size);
2551 +    snprintf(tmp,sizeof(tmp)-1,"'%s' spooled (%d KB [compressed])",file,size);
2552    else
2553 -    snprintf(MAXS(tmp),"'%s' spooled (%d KB)",file,size);
2554 +    snprintf(tmp,sizeof(tmp)-1,"'%s' spooled (%d KB)",file,size);
2555    message(prg,'I',tmp);
2556  }
2557  
2558 diff --git a/src/sendfiled.c b/src/sendfiled.c
2559 index eb25612..39715e5 100644
2560 --- a/src/sendfiled.c
2561 +++ b/src/sendfiled.c
2562 @@ -655,7 +655,7 @@ int main(int argc, char *argv[]) {
2563         }
2564         if (str_eq(line,"path")) {
2565           if (*argp == '/') { 
2566 -           snprintf(MAXS(path),"PATH=%s",argp);
2567 +           snprintf(path,sizeof(path)-1,"PATH=%s",argp);
2568             putenv(path);
2569           }
2570           continue;
2571 @@ -665,7 +665,7 @@ int main(int argc, char *argv[]) {
2572           continue;
2573         }
2574         if (str_eq(line,"forcepgp")) {
2575 -         snprintf(MAXS(sys_forcepgp),"%s",argp);
2576 +         snprintf(sys_forcepgp,sizeof(sys_forcepgp)-1,"%s",argp);
2577           continue;
2578         }
2579         if (str_eq(line,"spooling")) {
2580 @@ -896,7 +896,7 @@ int main(int argc, char *argv[]) {
2581        strcpy(forcepgp,sys_forcepgp);
2582  
2583        /* parse the user config-file */
2584 -      snprintf(MAXS(tmp),"%s/config",userconfig);
2585 +      snprintf(tmp,sizeof(tmp)-1,"%s/config",userconfig);
2586        setreugid();
2587        if ((inf=rfopen(tmp,"r"))) {
2588         while ((fgetl(line,inf))) {
2589 @@ -935,7 +935,7 @@ int main(int argc, char *argv[]) {
2590  
2591             /* pgp force option */
2592             if (str_eq(line,"forcepgp")) {
2593 -             snprintf(MAXS(forcepgp),"%s",argp);
2594 +             snprintf(forcepgp,sizeof(forcepgp)-1,"%s",argp);
2595               continue;
2596             }
2597  
2598 @@ -946,7 +946,7 @@ int main(int argc, char *argv[]) {
2599               if (str_beq(argp,"mail"))    strcpy(notification,"m");
2600               if (str_eq(argp,"both"))     strcpy(notification,"b");
2601               if (str_eq(argp,"program")) 
2602 -               snprintf(MAXS(notification),"%s/notify ",userconfig);
2603 +               snprintf(notification,sizeof(notification)-1,"%s/notify ",userconfig);
2604               else {
2605  
2606                 /* mail address specified to send notifications to? */
2607 @@ -1038,18 +1038,18 @@ int main(int argc, char *argv[]) {
2608        peer=peername(0);
2609        if (str_eq(peer,"localhost")) peer=localhost;
2610        if (strlen(arg)+strlen(peer)+strlen(real)+4<MAXLEN) {
2611 -       snprintf(MAXS(utfsender),"%s@%s %s",arg,peer,real);
2612 -       snprintf(MAXS(tmp),"%s@%s (%s)",arg,peer,real);
2613 +       snprintf(utfsender,sizeof(utfsender)-1,"%s@%s %s",arg,peer,real);
2614 +       snprintf(tmp,sizeof(tmp)-1,"%s@%s (%s)",arg,peer,real);
2615         utf2iso(0,sender,NULL,NULL,tmp);
2616         if ((cp=strchr(utfsender,' '))) {
2617           *cp=0;
2618 -         snprintf(MAXS(logsender),"%s (%s)",utfsender,cp+1);
2619 +         snprintf(logsender,sizeof(logsender)-1,"%s (%s)",utfsender,cp+1);
2620           *cp=' ';
2621         } else
2622           strcpy(logsender,utfsender);
2623        } else {
2624 -       snprintf(MAXS(utfsender),"???@%s",peer);
2625 -       snprintf(MAXS(sender),"???@%s",peer);
2626 +       snprintf(utfsender,sizeof(utfsender)-1,"???@%s",peer);
2627 +       snprintf(sender,sizeof(sender)-1,"???@%s",peer);
2628        }
2629  
2630        reply(200);
2631 @@ -1087,7 +1087,7 @@ int main(int argc, char *argv[]) {
2632        if ((cp=strchr(date,'T'))) *cp=' ';
2633        if (!strchr(date,'-')) {
2634         strcpy(tmp,date);
2635 -       snprintf(MAXS(date),"%c%c%c%c-%c%c-%c%c %c%c:%c%c:%c%c",
2636 +       snprintf(date,sizeof(date)-1,"%c%c%c%c-%c%c-%c%c %c%c:%c%c:%c%c",
2637                 tmp[0],tmp[1],tmp[2],tmp[3],
2638                 tmp[4],tmp[5],
2639                 tmp[6],tmp[7],
2640 @@ -1402,7 +1402,7 @@ int main(int argc, char *argv[]) {
2641        timetick=time(0);
2642        if (bell) strcat(msg,"\007");
2643        strftime(currentdate,9,"%H:%M",localtime(&timetick));
2644 -      snprintf(MAXS(msgh),"Message from %s at %s :",sender,currentdate);
2645 +      snprintf(msgh,sizeof(msgh)-1,"Message from %s at %s :",sender,currentdate);
2646  
2647        /* try to send to recipient ttys */
2648        if (msg2tty(recipient,msgh,msg,O_SYNC)<0)
2649 @@ -1412,7 +1412,7 @@ int main(int argc, char *argv[]) {
2650         /* log sender address */
2651         if (rgid) setegid(rgid);
2652         if (ruid) seteuid(ruid);
2653 -       snprintf(MAXS(tmp),"%s/msg@%s",userconfig,localhost);
2654 +       snprintf(tmp,sizeof(tmp)-1,"%s/msg@%s",userconfig,localhost);
2655         if ((outf=rfopen(tmp,"w"))) {
2656           strcpy(tmp,sender);
2657           if ((cp=strchr(tmp,' '))) *cp=0;
2658 @@ -1566,7 +1566,7 @@ int main(int argc, char *argv[]) {
2659  
2660           /* open spool data file for appending */
2661           id=flp->id;
2662 -         snprintf(MAXS(sdfile),"%d.d",id);
2663 +         snprintf(sdfile,sizeof(sdfile)-1,"%d.d",id);
2664           sdfd=open(sdfile,O_WRONLY|O_APPEND|O_LARGEFILE,S_IRUSR|S_IWUSR);
2665           if (sdfd<0) notify_reply(&notify,notification,sender,recipient,
2666                                    mailto,bell,412);
2667 @@ -1608,8 +1608,8 @@ int main(int argc, char *argv[]) {
2668             notify_reply(&notify,notification,sender,recipient,mailto,bell,413);
2669           
2670           /* open spool header and data files */
2671 -         snprintf(MAXS(shfile),"%d.h",id);
2672 -         snprintf(MAXS(sdfile),"%d.d",id);
2673 +         snprintf(shfile,sizeof(shfile)-1,"%d.h",id);
2674 +         snprintf(sdfile,sizeof(sdfile)-1,"%d.d",id);
2675           sdfd=open(sdfile,O_WRONLY|O_CREAT|O_LARGEFILE,S_IRUSR|S_IWUSR);
2676           shfd=open(shfile,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR);
2677           if (shfd<0 || sdfd<0) notify_reply(&notify,notification,sender,
2678 @@ -1734,7 +1734,7 @@ int main(int argc, char *argv[]) {
2679         if (*rpipe) {
2680  
2681           /* open post-processing pipe */
2682 -         snprintf(MAXS(tmp),"cat %s/%s %s/%s | %s && rm -f %s/%s %s/%s",
2683 +         snprintf(tmp,sizeof(tmp)-1,"cat %s/%s %s/%s | %s && rm -f %s/%s %s/%s",
2684                    userspool,shfile,
2685                    userspool,sdfile,
2686                    rpipe,                            
2687 @@ -1817,7 +1817,7 @@ int main(int argc, char *argv[]) {
2688                 (str_eq(date,flp->date) || !*date) &&
2689                 flags==flp->flags) {
2690               /* with same sizes? */
2691 -             snprintf(MAXS(tmp),"%lld %lld",flp->csize,flp->osize);
2692 +             snprintf(tmp,sizeof(tmp)-1,"%lld %lld",flp->csize,flp->osize);
2693               if (str_eq(tmp,sizes)) {
2694  
2695                 /* number of bytes already transmitted */
2696 @@ -1931,14 +1931,14 @@ int main(int argc, char *argv[]) {
2697        setreugid();
2698  
2699        /* write challenge file */
2700 -      snprintf(MAXS(chfile),"tmp_challenge_%d",(int)getpid());
2701 +      snprintf(chfile,sizeof(chfile)-1,"tmp_challenge_%d",(int)getpid());
2702        outf=rfopen(chfile,"w");
2703        if (!outf) reply(410);
2704        fprintf(outf,"%d",challenge);
2705        fclose(outf);
2706        
2707        /* write challenge signature file */
2708 -      snprintf(MAXS(csfile),"tmp_challenge_%d.asc",(int)getpid());
2709 +      snprintf(csfile,sizeof(csfile)-1,"tmp_challenge_%d.asc",(int)getpid());
2710        unlink(csfile);
2711        outf=rfopen(csfile,"w");
2712        if (!outf) {
2713 @@ -1954,7 +1954,7 @@ int main(int argc, char *argv[]) {
2714   * pgp -sbaf +clearsig=on +secring=private.pgp +pubring=private.pgp
2715   */
2716        
2717 -      snprintf(MAXS(tmp),"%s +pubring=config/public.pgp %s %s 2>/dev/null",
2718 +      snprintf(tmp,sizeof(tmp)-1,"%s +pubring=config/public.pgp %s %s 2>/dev/null",
2719                pgp_bin,csfile,chfile);
2720        pp=popen(tmp,"r");
2721        if (!pp) {
2722 @@ -2009,7 +2009,7 @@ int main(int argc, char *argv[]) {
2723        }
2724        
2725        /* change to user config directory */
2726 -      snprintf(MAXS(tmp),"%s/config",userspool);
2727 +      snprintf(tmp,sizeof(tmp)-1,"%s/config",userspool);
2728        if (chdir(tmp)<0) reply(410);
2729  
2730        /* change effective uid and gid to recipient */
2731 @@ -2138,7 +2138,7 @@ int main(int argc, char *argv[]) {
2732         setreugid();
2733  
2734         /* open header file */
2735 -       snprintf(MAXS(shfile),"%d.h",id);
2736 +       snprintf(shfile,sizeof(shfile)-1,"%d.h",id);
2737         if (!(inf=rfopen(shfile,"r"))) reply(550);
2738  
2739         /* read and transfer header file */
2740 @@ -2163,7 +2163,7 @@ int main(int argc, char *argv[]) {
2741         setreugid();
2742  
2743         /* open spool data file */
2744 -       snprintf(MAXS(sdfile),"%d.d",id);
2745 +       snprintf(sdfile,sizeof(sdfile)-1,"%d.d",id);
2746         if (stat(sdfile,&finfo)<0 || (infd=open(sdfile,O_RDONLY|O_LARGEFILE))<0) reply(550);
2747         if (transmitted>finfo.st_size) {
2748           reply(507);
2749 @@ -2434,7 +2434,7 @@ void writeheader(int fd, const char *attribute, const char *value) {
2750    int hsize;                   /* header string size */
2751    char header[2*MAXLEN];       /* header string */
2752  
2753 -  snprintf(MAXS(header),"%s\t%s\n",attribute,value);
2754 +  snprintf(header,sizeof(header)-1,"%s\t%s\n",attribute,value);
2755    hsize=strlen(header);
2756    if (write(fd,header,hsize)<hsize) reply(412);
2757  }
2758 @@ -2537,7 +2537,7 @@ int msg2tty(const char *recipient, const char *msgh, char *msg, int mode) {
2759    /* change effective uid to recipient for security reasons */
2760    setreugid();
2761  
2762 -  snprintf(MAXS(msgcf),"%s/config/tty@%s",userspool,localhost);
2763 +  snprintf(msgcf,sizeof(msgcf)-1,"%s/config/tty@%s",userspool,localhost);
2764  
2765    /* force writing to all ttys which are open? */
2766    if (*msg && str_beq(msg,"wall!")) {
2767 @@ -2546,9 +2546,9 @@ int msg2tty(const char *recipient, const char *msgh, char *msg, int mode) {
2768    }
2769  
2770    if (*msg)
2771 -    snprintf(MAXS(output),"\r\n%s\n\r%s\r\n",msgh,msg);
2772 +    snprintf(output,sizeof(output)-1,"\r\n%s\n\r%s\r\n",msgh,msg);
2773    else
2774 -    snprintf(MAXS(output),"\r\n%s\n\r",msgh);
2775 +    snprintf(output,sizeof(output)-1,"\r\n%s\n\r",msgh);
2776      
2777    /* is there a message control file? */
2778    if (!wall && success<=0 && (inf=rfopen(msgcf,"r"))) {
2779 @@ -2586,7 +2586,7 @@ int msg2tty(const char *recipient, const char *msgh, char *msg, int mode) {
2780      /* scan through utmp (currently logged in users) */
2781      while (read(utmpfd,(char *)&uinfo,sizeof(uinfo))>0) {
2782        
2783 -#if defined(NEXT) || defined(BSD) || defined(ULTRIX) || defined(SOLARIS1)
2784 +#if defined(NEXT) || defined(BSD) || defined(ULTRIX) || defined(SOLARIS1) || defined(__APPLE__)
2785        strncpy(user,uinfo.ut_name,8);
2786        if (str_eq(recipient,user)) {
2787         
2788 @@ -2598,7 +2598,7 @@ int msg2tty(const char *recipient, const char *msgh, char *msg, int mode) {
2789        if (uinfo.ut_type==USER_PROCESS && str_eq(recipient,user)) {
2790  #endif
2791         /* get the tty */
2792 -       snprintf(MAXS(tty),"/dev/%s",uinfo.ut_line);
2793 +       snprintf(tty,sizeof(tty)-1,"/dev/%s",uinfo.ut_line);
2794  
2795         /* is the tty writeable? */
2796         if (stat(tty,&finfo)==0 &&
2797 @@ -2664,7 +2664,7 @@ void mail2user(const char *recipient, const char *sender, const char *msg) {
2798    while ((cp=strchr(sender,'\''))) *cp=' ';
2799  
2800    /* open pipe to sendmail */
2801 -  snprintf(MAXS(cmd),SENDMAIL" %s",recipient);
2802 +  snprintf(cmd,sizeof(cmd)-1,SENDMAIL" %s",recipient);
2803    pout=popen(cmd,"w");
2804  
2805    /* fill out mail message */
2806 @@ -2730,7 +2730,7 @@ int restricted(const char *sender, const char *recipient, char type) {
2807  
2808    setreugid();
2809    
2810 -  snprintf(MAXS(killfile),"%s/config/restrictions",userspool);
2811 +  snprintf(killfile,sizeof(killfile)-1,"%s/config/restrictions",userspool);
2812    *kfm=*kfu=0;
2813  
2814    /* open and check killfile */
2815 @@ -2786,9 +2786,9 @@ off_t free_space() {
2816  #endif
2817  
2818    if (*userspool)
2819 -    snprintf(MAXS(spool),"%s/.",userspool);
2820 +    snprintf(spool,sizeof(spool)-1,"%s/.",userspool);
2821    else
2822 -    snprintf(MAXS(spool),"%s/.",SPOOL);
2823 +    snprintf(spool,sizeof(spool)-1,"%s/.",SPOOL);
2824      
2825  #if defined(IRIX) || defined(IRIX64)
2826    if (statfs(spool,&fsinfo,sizeof(struct statfs),0)==0)
2827 @@ -2838,7 +2838,7 @@ int get_sizes(char *string, off_t *size, off_t *osize) {
2828  
2829    /* get maximum file size for this process */
2830  #ifdef RLIMIT_FSIZE
2831 -  if (getrlimit(RLIMIT_FSIZE,&rl)==0) snprintf(MAXS(max),"%llu",rl.rlim_cur);
2832 +  if (getrlimit(RLIMIT_FSIZE,&rl)==0) snprintf(max,sizeof(max)-1,"%llu",rl.rlim_cur);
2833  #endif    
2834    
2835    /* get compressed and original file size string */
2836 @@ -2883,10 +2883,10 @@ int send_msg(const char *msg, const char *to, const char *recipient) {
2837    cp=strchr(to,'@');
2838    if (cp) {
2839      *cp=0;
2840 -    snprintf(MAXS(user),"%s",to);
2841 -    snprintf(MAXS(host),"%s",cp+1);
2842 +    snprintf(user,sizeof(user)-1,"%s",to);
2843 +    snprintf(host,sizeof(host)-1,"%s",cp+1);
2844    } else {
2845 -    snprintf(MAXS(user),"%s",to);
2846 +    snprintf(user,sizeof(user)-1,"%s",to);
2847      strcpy(host,localhost);
2848    }
2849  
2850 @@ -2901,24 +2901,24 @@ int send_msg(const char *msg, const char *to, const char *recipient) {
2851    sock_getline(sockfd,line);
2852    if (!str_beq(line,"220 ") || !strstr(line,"SAFT")) return(-1);
2853  /*
2854 -  snprintf(MAXS(tmp),"connected to %s",host);
2855 +  snprintf(tmp,sizeof(tmp)-1,"connected to %s",host);
2856    dbgout(tmp);
2857  */  
2858 -  snprintf(MAXS(line),"FROM %s autogenerated+ACA-SAFT+ACA-message",recipient);
2859 -  snprintf(MAXS(line),"FROM %s",recipient);
2860 +  snprintf(line,sizeof(line)-1,"FROM %s autogenerated+ACA-SAFT+ACA-message",recipient);
2861 +  snprintf(line,sizeof(line)-1,"FROM %s",recipient);
2862    sock_putline(sockfd,line);
2863    if (!str_beq(getreply(sockfd),"200 ")) {
2864      close(sockfd);
2865      return(-1);  
2866    }
2867 -  snprintf(MAXS(line),"TO %s",user);
2868 +  snprintf(line,sizeof(line)-1,"TO %s",user);
2869    sock_putline(sockfd,line);
2870    if (!str_beq(getreply(sockfd),"200 ")) {
2871      close(sockfd);
2872      return(-1);  
2873    }
2874    iso2utf(tmp,(char*)msg);
2875 -  snprintf(MAXS(line),"MSG %s",tmp);
2876 +  snprintf(line,sizeof(line)-1,"MSG %s",tmp);
2877    sock_putline(sockfd,line);
2878    if (!str_beq(getreply(sockfd),"200 ")) {
2879      close(sockfd);
2880 @@ -2978,7 +2978,7 @@ int sfsd(int queue, int parallel, int bounce, int retry, float mtp) {
2881    /* test outgoing spool */
2882    if (chdir(OUTGOING)<0) {
2883      if (queue==1) message(prg,'F',OUTGOING);
2884 -    snprintf(MAXS(tmp),OUTGOING" : %s",strerror(errno));
2885 +    snprintf(tmp,sizeof(tmp)-1,OUTGOING" : %s",strerror(errno));
2886      dbgout(tmp);
2887      exit(1);
2888    }
2889 @@ -3022,16 +3022,16 @@ int sfsd(int queue, int parallel, int bounce, int retry, float mtp) {
2890      /* relock */
2891      unlink(lockfn);
2892      if ((lockf=open(lockfn,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR))<0) {
2893 -      snprintf(MAXS(tmp),"cannot open %s : %s",lockfn,strerror(errno));
2894 +      snprintf(tmp,sizeof(tmp)-1,"cannot open %s : %s",lockfn,strerror(errno));
2895        dbgout(tmp);
2896        exit(1);
2897      }
2898      if (wlock_file(lockf)<0) {
2899 -      snprintf(MAXS(tmp),"cannot lock %s : %s",lockfn,strerror(errno));
2900 +      snprintf(tmp,sizeof(tmp)-1,"cannot lock %s : %s",lockfn,strerror(errno));
2901        dbgout(tmp);
2902        exit(1);
2903      }
2904 -    snprintf(MAXS(tmp),"%d\n",(int)getpid());
2905 +    snprintf(tmp,sizeof(tmp)-1,"%d\n",(int)getpid());
2906      write(lockf,tmp,strlen(tmp));
2907  
2908      /* disconnect from client */
2909 @@ -3079,7 +3079,7 @@ int sfsd(int queue, int parallel, int bounce, int retry, float mtp) {
2910           continue;
2911         }
2912         
2913 -       snprintf(MAXS(tmp),"connected to %s",hlp->host);
2914 +       snprintf(tmp,sizeof(tmp)-1,"connected to %s",hlp->host);
2915         if (queue==1) message(prg,'I',tmp);
2916         dbgout(tmp);
2917         
2918 @@ -3126,7 +3126,7 @@ int sfsd(int queue, int parallel, int bounce, int retry, float mtp) {
2919  
2920                 /* same host? */
2921                 if (str_eq(hlp->host,ahost)) {
2922 -                 snprintf(MAXS(line),"TO %s",arecipient);
2923 +                 snprintf(line,sizeof(line)-1,"TO %s",arecipient);
2924                   sock_putline(sockfd,line);
2925                   rs=getreply(sockfd);
2926                   if (!str_beq(rs,"200")) {
2927 @@ -3150,7 +3150,7 @@ int sfsd(int queue, int parallel, int bounce, int retry, float mtp) {
2928                   break;
2929                 }
2930                 
2931 -               snprintf(MAXS(tmp),"connected to %s (forward redirection)",
2932 +               snprintf(tmp,sizeof(tmp)-1,"connected to %s (forward redirection)",
2933                          hlp->host);
2934                 if (queue==1) message(prg,'I',tmp);
2935                 dbgout(tmp);
2936 @@ -3252,7 +3252,7 @@ int sfsd(int queue, int parallel, int bounce, int retry, float mtp) {
2937      while ((ssec=t0-time(0)+retry*60)>0) {
2938        sigchld();
2939        signal(SIGCHLD,sigchld);
2940 -      snprintf(MAXS(tmp),"sleep %d s",ssec);
2941 +      snprintf(tmp,sizeof(tmp)-1,"sleep %d s",ssec);
2942        dbgout(tmp);
2943        sleep(ssec);
2944      }
2945 @@ -3291,17 +3291,17 @@ int send_spooldata(int sockfd, char *oshfn, char *from, char *to,
2946    /* status report */
2947    if (queue) {
2948      utf2iso(0,isoname,NULL,NULL,fname);
2949 -    snprintf(MAXS(tmp),"sending %s to %s",isoname,to);
2950 +    snprintf(tmp,sizeof(tmp)-1,"sending %s to %s",isoname,to);
2951      message(prg,'I',tmp);
2952    }
2953                 
2954 -  snprintf(MAXS(tmp),"sending %s to %s@%s",fname,to,host);
2955 +  snprintf(tmp,sizeof(tmp)-1,"sending %s to %s@%s",fname,to,host);
2956    dbgout(tmp);
2957  
2958    strcpy(osdfn,oshfn);
2959    osdfn[strlen(osdfn)-1]='d';
2960    if (stat(osdfn,&finfo)<0) {
2961 -    snprintf(MAXS(tmp),"cannot access %s",osdfn);
2962 +    snprintf(tmp,sizeof(tmp)-1,"cannot access %s",osdfn);
2963      dbgout(tmp);
2964      return(-1);
2965    }
2966 @@ -3318,10 +3318,10 @@ int send_spooldata(int sockfd, char *oshfn, char *from, char *to,
2967    
2968    /* write status log */
2969    mkdir(SPOOL"/LOG",S_IRUSR|S_IWUSR|S_IXUSR);
2970 -  snprintf(MAXS(tmp),SPOOL"/LOG/%s:%s",from,host);
2971 +  snprintf(tmp,sizeof(tmp)-1,SPOOL"/LOG/%s:%s",from,host);
2972    if ((mailf=rfopen(tmp,"a"))) {
2973      chmod(tmp,S_IRUSR|S_IWUSR);
2974 -    snprintf(MAXS(tmp),"'%s' to %s",fname,to);
2975 +    snprintf(tmp,sizeof(tmp)-1,"'%s' to %s",fname,to);
2976      utf2iso(1,line,NULL,NULL,tmp);
2977      timetick=time(0);
2978      strftime(tmp,21,DATEFORMAT,localtime(&timetick));
2979 @@ -3375,14 +3375,14 @@ int saftserver_connect(char *host, char *error) {
2980    for (hopcount=1; hopcount<11; hopcount++) {
2981       
2982      /* tell where to send to */
2983 -    snprintf(MAXS(tmp),"opening connection to %s:%d",host,port);
2984 +    snprintf(tmp,sizeof(tmp)-1,"opening connection to %s:%d",host,port);
2985      dbgout(tmp);
2986  
2987      /* initiate the connection to the server */
2988      sockfd=open_connection(host,port);
2989      if (sockfd==-3 && port==SAFT) {
2990 -      snprintf(MAXS(server),"saft.%s",host); 
2991 -      snprintf(MAXS(tmp),"opening connection to %s:%d",server,SAFT);
2992 +      snprintf(server,sizeof(server)-1,"saft.%s",host); 
2993 +      snprintf(tmp,sizeof(tmp)-1,"opening connection to %s:%d",server,SAFT);
2994        dbgout(tmp);
2995        sockfd=open_connection(server,SAFT);
2996        switch (sockfd) {
2997 @@ -3419,7 +3419,7 @@ int saftserver_connect(char *host, char *error) {
2998      status=check_forward(sockfd,tmp,host,error);
2999      if (status==-1) return(-1);
3000      if (status==1) {
3001 -      snprintf(MAXS(tmp),"forward points to %s",host);
3002 +      snprintf(tmp,sizeof(tmp)-1,"forward points to %s",host);
3003        dbgout(tmp);
3004        colon=NULL;
3005        port=487;
3006 @@ -3427,7 +3427,7 @@ int saftserver_connect(char *host, char *error) {
3007      }
3008  
3009      /* connection is successfull */
3010 -    snprintf(MAXS(tmp),"connected to %s:%d",host,port);
3011 +    snprintf(tmp,sizeof(tmp)-1,"connected to %s:%d",host,port);
3012      *error=0;
3013      dbgout(tmp);
3014      return(sockfd);
3015 @@ -3477,14 +3477,14 @@ int saftserver_connect(char *host, char *error) {
3016    for (hopcount=1; hopcount<11; hopcount++) {
3017       
3018      /* tell where to send to */
3019 -    snprintf(MAXS(tmp),"opening connection to %s:%s",host,service);
3020 +    snprintf(tmp,sizeof(tmp)-1,"opening connection to %s:%s",host,service);
3021      dbgout(tmp);
3022  
3023      /* initiate the connection to the server */
3024      sockfd=open_connection(host,service);
3025      if (sockfd==-3 && (strcasecmp(service, SERVICE) == 0 || strcmp(service, PORT_STRING) == 0)) {
3026 -      snprintf(MAXS(server),"saft.%s",host); 
3027 -      snprintf(MAXS(tmp),"opening connection to %s:%s",server,SERVICE);
3028 +      snprintf(server,sizeof(server)-1,"saft.%s",host); 
3029 +      snprintf(tmp,sizeof(tmp)-1,"opening connection to %s:%s",server,SERVICE);
3030        dbgout(tmp);
3031        sockfd=open_connection(server,SERVICE);
3032        switch (sockfd) {
3033 @@ -3523,7 +3523,7 @@ int saftserver_connect(char *host, char *error) {
3034      status=check_forward(sockfd,tmp,host,error);
3035      if (status==-1) return(-1);
3036      if (status==1) {
3037 -      snprintf(MAXS(tmp),"forward points to %s",host);
3038 +      snprintf(tmp,sizeof(tmp)-1,"forward points to %s",host);
3039        dbgout(tmp);
3040        colon=NULL;
3041        service = SERVICE;
3042 @@ -3531,7 +3531,7 @@ int saftserver_connect(char *host, char *error) {
3043      }
3044  
3045      /* connection is successfull */
3046 -    snprintf(MAXS(tmp),"connected to %s:%s",host,service);
3047 +    snprintf(tmp,sizeof(tmp)-1,"connected to %s:%s",host,service);
3048      *error=0;
3049      dbgout(tmp);
3050      return(sockfd);
3051 @@ -3576,7 +3576,7 @@ int mail_report(const char *host) {
3052    /* stupid NeXT has a broken readdir(); this is a dirty workaround */
3053  
3054    /* open LOG dir */
3055 -  snprintf(MAXS(cmd),"ls *:%s 2>/dev/null",host);
3056 +  snprintf(cmd,sizeof(cmd)-1,"ls *:%s 2>/dev/null",host);
3057    if ((dp=popen(cmd,"r")) == NULL) {
3058      exit(0);
3059      if (parallel) continue;
3060 @@ -3597,7 +3597,7 @@ int mail_report(const char *host) {
3061    while ((dire=readdir(dp))) {
3062      
3063      strcpy(mailfn,dire->d_name);
3064 -    snprintf(MAXS(tmp),"*:%s",host);
3065 +    snprintf(tmp,sizeof(tmp)-1,"*:%s",host);
3066      if (simplematch(mailfn,tmp,0)<1) continue;
3067  #endif
3068      mailf=rfopen(mailfn,"r");
3069 @@ -3693,7 +3693,7 @@ void check_outspool(int bounce) {
3070    while ((dire=readdir(dp))) {
3071     
3072      /* ignore non-header files */
3073 -    snprintf(MAXS(oshfn),"%s",dire->d_name);
3074 +    snprintf(oshfn,sizeof(oshfn)-1,"%s",dire->d_name);
3075      if (!str_eq(&oshfn[strlen(oshfn)-2],".h")) continue;
3076  #endif
3077  
3078 @@ -3703,7 +3703,7 @@ void check_outspool(int bounce) {
3079  
3080      /* spool time expired? */
3081      if (timetick>finfo.st_mtime+bounce*DAYSEC) {
3082 -      snprintf(MAXS(tmp),"no connection within %d days",bounce);
3083 +      snprintf(tmp,sizeof(tmp)-1,"no connection within %d days",bounce);
3084        bounce_file(oshfn,tmp);
3085      }
3086    }
3087 @@ -3749,8 +3749,8 @@ int bounce_file(char *file, char *comment) {
3088      cp++;
3089    else
3090      cp=file;
3091 -  snprintf(MAXS(oshfn),OUTGOING"/%s",cp);
3092 -  snprintf(MAXS(osdfn),OUTGOING"/%s",cp);
3093 +  snprintf(oshfn,sizeof(oshfn)-1,OUTGOING"/%s",cp);
3094 +  snprintf(osdfn,sizeof(osdfn)-1,OUTGOING"/%s",cp);
3095    osdfn[strlen(osdfn)-1]='d';
3096    
3097    if (stat(oshfn,&finfo)<0) return(-1);
3098 @@ -3758,7 +3758,7 @@ int bounce_file(char *file, char *comment) {
3099  
3100    /* get user name and spool directory */
3101    if (!(pwe=getpwuid(finfo.st_uid))) return(-1);
3102 -  snprintf(MAXS(userspool),SPOOL"/%s",pwe->pw_name);
3103 +  snprintf(userspool,sizeof(userspool)-1,SPOOL"/%s",pwe->pw_name);
3104  
3105    /* create user spool directory if necessary */
3106    if (mkdir(userspool,S_IRUSR|S_IWUSR|S_IXUSR)==0)
3107 @@ -3788,8 +3788,8 @@ int bounce_file(char *file, char *comment) {
3108    }
3109  
3110    /* set file names */
3111 -  snprintf(MAXS(shfn),"%d.h",id);
3112 -  snprintf(MAXS(sdfn),"%d.d",id);
3113 +  snprintf(shfn,sizeof(shfn)-1,"%d.h",id);
3114 +  snprintf(sdfn,sizeof(sdfn)-1,"%d.d",id);
3115  
3116    if (!(outf=rfopen(shfn,"w"))) {
3117      fclose(inf);
3118 @@ -3814,7 +3814,7 @@ int bounce_file(char *file, char *comment) {
3119  
3120      /* add new bounce COMMENT */
3121      if (str_eq(hline,"TO")) {
3122 -      snprintf(MAXS(tmp),"cannot sent to %s : %s",arg,comment);
3123 +      snprintf(tmp,sizeof(tmp)-1,"cannot sent to %s : %s",arg,comment);
3124        iso2utf(arg,tmp);
3125        fprintf(outf,"COMMENT\t%s\n",arg);
3126        continue;
3127 @@ -3930,7 +3930,7 @@ int check_userspool(char *user, int userconfighome) {
3128    pwe=NULL;
3129  #ifdef NEXT
3130    /* stupid NeXT has a broken getpwnam(); this is a dirty workaround */
3131 -  snprintf(MAXS(tmp),"( nidump passwd . ; nidump passwd / ) | "
3132 +  snprintf(tmp,sizeof(tmp)-1,"( nidump passwd . ; nidump passwd / ) | "
3133                "awk -F: '$1==\"%s\"{print $3,$4;exit}'",user);
3134    pp=popen(tmp,"r");
3135    if (fgetl(tmp,pp) && *tmp!='\n' && *tmp!=0) {
3136 @@ -3958,8 +3958,8 @@ int check_userspool(char *user, int userconfighome) {
3137  
3138    /* build user spool string */
3139    user[32]=0;
3140 -  snprintf(MAXS(userspool),SPOOL"/%s",user);
3141 -  snprintf(MAXS(userconfig),"%s/config",userspool);
3142 +  snprintf(userspool,sizeof(userspool)-1,SPOOL"/%s",user);
3143 +  snprintf(userconfig,sizeof(userconfig)-1,"%s/config",userspool);
3144  
3145    /* create user spool directory for user */
3146    if (mkdir(userspool,S_IRUSR|S_IWUSR|S_IXUSR)==0) chown(userspool,ruid,rgid);
3147 @@ -4173,14 +4173,16 @@ void cleanup() {
3148   * RETURN: nothing, but terminates program on error
3149   */
3150  void setreugid() {
3151 -  if (rgid && setegid(rgid)<0) {
3152 -    printf("490 Internal error on setegid(%u): %s\r\n",
3153 -          (unsigned int)rgid,strerror(errno));
3154 +  if (rgid && rgid != getegid() && setegid(rgid)<0) {
3155 +    printf("490 Internal error on setegid(%u): %s [%u/%u]\r\n",
3156 +          (unsigned int)rgid,strerror(errno),
3157 +          geteuid(), getegid());
3158      exit(1);
3159    }
3160 -  if (ruid && seteuid(ruid)<0) {
3161 -    printf("490 Internal error on seteuid(%u): %s\r\n",
3162 -          (unsigned int)ruid,strerror(errno));
3163 +  if (ruid && ruid != geteuid() && seteuid(ruid)<0) {
3164 +    printf("490 Internal error on seteuid(%u): %s [%u/%u]\r\n",
3165 +          (unsigned int)ruid,strerror(errno),
3166 +          geteuid(), getegid());
3167      exit(1);
3168    }
3169  }
3170 @@ -4222,13 +4224,13 @@ int sudo(const char *user, const char *cmd) {
3171    if (setuid(pwe->pw_uid)<0) exit(1);
3172  
3173    /* set some usefull environment variables */
3174 -  snprintf(MAXS(tmp),"HOME=%s",pwe->pw_dir);
3175 +  snprintf(tmp,sizeof(tmp)-1,"HOME=%s",pwe->pw_dir);
3176    putenv(tmp);
3177 -  snprintf(MAXS(tmp),"SHELL=%s",pwe->pw_shell);
3178 +  snprintf(tmp,sizeof(tmp)-1,"SHELL=%s",pwe->pw_shell);
3179    putenv(tmp);
3180 -  snprintf(MAXS(tmp),"USER=%s",user);
3181 +  snprintf(tmp,sizeof(tmp)-1,"USER=%s",user);
3182    putenv(tmp);
3183 -  snprintf(MAXS(tmp),"LOGNAME=%s",user);
3184 +  snprintf(tmp,sizeof(tmp)-1,"LOGNAME=%s",user);
3185    putenv(tmp);
3186    putenv("TERM=");
3187    
3188 diff --git a/src/sendmsg.c b/src/sendmsg.c
3189 index 23c60b1..2dd4318 100644
3190 --- a/src/sendmsg.c
3191 +++ b/src/sendmsg.c
3192 @@ -260,10 +260,10 @@ int main(int argc, char *argv[]) {
3193      else {
3194     
3195        /* test if you can receive messages */
3196 -      snprintf(MAXS(line),"FROM %s",login);
3197 +      snprintf(line,sizeof(line)-1,"FROM %s",login);
3198        sock_putline(sockfd,line);
3199        sock_getline(sockfd,line);
3200 -      snprintf(MAXS(line),"TO %s",login);
3201 +      snprintf(line,sizeof(line)-1,"TO %s",login);
3202        sock_putline(sockfd,line);
3203        sock_getline(sockfd,line);
3204        if (str_beq(line,"521 ")) {
3205 @@ -281,7 +281,7 @@ int main(int argc, char *argv[]) {
3206          else {
3207  
3208           /* the message tty config file */
3209 -         snprintf(MAXS(msgcf),"%s/%s/config/tty@%s",SPOOL,login,localhost);
3210 +         snprintf(msgcf,sizeof(msgcf)-1,"%s/%s/config/tty@%s",SPOOL,login,localhost);
3211  
3212           /* open tty write permissions if necessary */
3213           if (receive) {
3214 @@ -293,14 +293,14 @@ int main(int argc, char *argv[]) {
3215                 fprintf(outf,"%s\n",tty);
3216                 fclose(outf);
3217                 if (chmod(tty,S_IRUSR|S_IWUSR|S_IWGRP)<0) {
3218 -                 snprintf(MAXS(tmp),"cannot open your tty %s for writing",tty);
3219 +                 snprintf(tmp,sizeof(tmp)-1,"cannot open your tty %s for writing",tty);
3220                   message(prg,'W',tmp);
3221                 } else if (argc-optind<1) {
3222                   message(prg,'I',
3223                           "receiving messages is now restricted to this tty");
3224                 }
3225               } else {
3226 -               snprintf(MAXS(tmp),"cannot configure your tty "
3227 +               snprintf(tmp,sizeof(tmp)-1,"cannot configure your tty "
3228                          "(no write access to %s)",msgcf);
3229                 message(prg,'W',tmp);
3230               }
3231 @@ -318,7 +318,7 @@ int main(int argc, char *argv[]) {
3232             /* is the current tty writable? */
3233             if (stat(tty,&finfo)<0 || !(finfo.st_mode&S_IWGRP)) {
3234               errno=0;
3235 -             snprintf(MAXS(tmp),"your tty %s is write protected; "
3236 +             snprintf(tmp,sizeof(tmp)-1,"your tty %s is write protected; "
3237                        "try sendmsg -m",tty);
3238               message(prg,'F',tmp);
3239             }
3240 @@ -401,7 +401,7 @@ int main(int argc, char *argv[]) {
3241        }
3242  
3243        /* send the message */
3244 -      snprintf(MAXS(tmp),"MSG %s",utf_msg);
3245 +      snprintf(tmp,sizeof(tmp)-1,"MSG %s",utf_msg);
3246        sendheader(sockfd,tmp);
3247        
3248      }
3249 @@ -433,7 +433,7 @@ int main(int argc, char *argv[]) {
3250        iso2utf(utf_msg,iso_msg);
3251  
3252        /* send the message */
3253 -      snprintf(MAXS(line),"MSG %s",utf_msg);
3254 +      snprintf(line,sizeof(line)-1,"MSG %s",utf_msg);
3255        sock_putline(sockfd,line);
3256        xonf=0;
3257        sr=getreply(sockfd);
3258 @@ -441,12 +441,12 @@ int main(int argc, char *argv[]) {
3259       
3260        if (!(str_beq(sr,"200") || str_beq(sr,"202"))) {
3261          if (strstr(sr,"Timeout")) {
3262 -          snprintf(MAXS(tmp),"server timeout");
3263 +          snprintf(tmp,sizeof(tmp)-1,"server timeout");
3264            message(prg,'W',tmp);
3265            sockfd=saft_connect("msg",recipient,user,host,tmp);
3266            sendheader(sockfd,line);
3267          } else {
3268 -          snprintf(MAXS(tmp),"server error: %s",sr+4);
3269 +          snprintf(tmp,sizeof(tmp)-1,"server error: %s",sr+4);
3270            message(prg,'X',tmp);
3271          }
3272        }
3273 diff --git a/src/spool.c b/src/spool.c
3274 index a1fdd8e..5f36085 100644
3275 --- a/src/spool.c
3276 +++ b/src/spool.c
3277 @@ -181,7 +181,7 @@ struct senderlist *scanspool(char *sender) {
3278    /* mega stupid NeXT has broken readdir() */
3279  #ifdef NEXT
3280    /* open spool dir */
3281 -  snprintf(MAXS(tmp),"ls %s 2>/dev/null",userspool);
3282 +  snprintf(tmp,sizeof(tmp)-1,"ls %s 2>/dev/null",userspool);
3283    if ((pp=popen(tmp,"r")) == NULL) return(NULL);
3284  
3285    /* scan through spool directory */
3286 @@ -216,7 +216,7 @@ struct senderlist *scanspool(char *sender) {
3287  #endif
3288  
3289        /* open header file */
3290 -      snprintf(MAXS(file),"%s/%d.h",userspool,id);
3291 +      snprintf(file,sizeof(file)-1,"%s/%d.h",userspool,id);
3292        hf=rfopen(file,"r");
3293        
3294        /* error? */
3295 @@ -224,7 +224,7 @@ struct senderlist *scanspool(char *sender) {
3296         
3297         /* called from receive client? */
3298         if (client) {
3299 -         snprintf(MAXS(msg),"cannot open spool file %s",file);
3300 +         snprintf(msg,sizeof(msg)-1,"cannot open spool file %s",file);
3301           message("",'E',msg);
3302         }
3303  
3304 @@ -246,9 +246,9 @@ struct senderlist *scanspool(char *sender) {
3305        compress="";
3306  
3307        /* does the spool data file exist? */
3308 -      snprintf(MAXS(file),"%s/%d.d",userspool,id);
3309 +      snprintf(file,sizeof(file)-1,"%s/%d.d",userspool,id);
3310        if (stat(file,&finfo)<0) {
3311 -       snprintf(MAXS(file),"%s/%d.h",userspool,id);
3312 +       snprintf(file,sizeof(file)-1,"%s/%d.h",userspool,id);
3313         unlink(file);
3314         continue;
3315        }
3316 @@ -260,7 +260,7 @@ struct senderlist *scanspool(char *sender) {
3317        if (keep>0 && (ctime-rtime)/DAYSEC>=keep) {
3318          fclose(hf);
3319         unlink(file);
3320 -       snprintf(MAXS(file),"%s/%d.h",userspool,id);
3321 +       snprintf(file,sizeof(file)-1,"%s/%d.h",userspool,id);
3322         unlink(file);
3323         continue;
3324        }
3325 @@ -293,7 +293,7 @@ struct senderlist *scanspool(char *sender) {
3326          if (str_eq(hline,"FROM")) {
3327           if ((cp=strchr(arg,' '))) {
3328             *cp=0;
3329 -           snprintf(MAXS(tmp),"%s (%s)",arg,cp+1);
3330 +           snprintf(tmp,sizeof(tmp)-1,"%s (%s)",arg,cp+1);
3331           } else
3332             strcpy(tmp,arg);
3333           utf2iso(0,from,NULL,NULL,tmp);
3334 @@ -372,9 +372,9 @@ struct senderlist *scanspool(char *sender) {
3335        /* junk file expired? */
3336        if (*from==0 || *fname==0 || 
3337           (tsize!=csize && deljunk>0 && (ctime-rtime)/DAYSEC>=deljunk)) {
3338 -        snprintf(MAXS(file),"%s/%d.d",userspool,id);
3339 +        snprintf(file,sizeof(file)-1,"%s/%d.d",userspool,id);
3340         unlink(file);
3341 -       snprintf(MAXS(file),"%s/%d.h",userspool,id);
3342 +       snprintf(file,sizeof(file)-1,"%s/%d.h",userspool,id);
3343         unlink(file);
3344         continue;
3345        }
3346 @@ -539,7 +539,7 @@ struct hostlist *scanoutspool(char *sender) {
3347    /* mega stupid NeXT has broken readdir() */
3348  #ifdef NEXT
3349    /* open spool dir */
3350 -  snprintf(MAXS(tmp),"cd %s;ls %s_*.h 2>/dev/null",OUTGOING,sender);
3351 +  snprintf(tmp,sizeof(tmp)-1,"cd %s;ls %s_*.h 2>/dev/null",OUTGOING,sender);
3352    if ((pp=popen(tmp,"r")) == NULL) return(NULL);
3353  
3354    /* scan through spool directory */
3355 @@ -561,18 +561,18 @@ struct hostlist *scanoutspool(char *sender) {
3356  #endif
3357  
3358      /* look for header files */
3359 -    snprintf(MAXS(tmp),"%s*.h",sender);
3360 +    snprintf(tmp,sizeof(tmp)-1,"%s*.h",sender);
3361      if (simplematch(hfn,tmp,1)==0) continue;
3362  
3363      strcpy(tmp,hfn);
3364 -    snprintf(MAXS(hfn),OUTGOING"/%s",tmp);
3365 +    snprintf(hfn,sizeof(hfn)-1,OUTGOING"/%s",tmp);
3366  
3367      /* open header file */
3368      if ((hf=rfopen(hfn,"r")) == NULL) {
3369       
3370        /* called from receive client? */
3371        if (client) {
3372 -        snprintf(MAXS(msg),"cannot open outgoing spool file %s",hfn);
3373 +        snprintf(msg,sizeof(msg)-1,"cannot open outgoing spool file %s",hfn);
3374         message("",'E',msg);
3375        }
3376  
3377 @@ -776,19 +776,19 @@ int delete_sf(struct filelist *flp, int verbose) {
3378    extern int client;           /* flag to determine client or server */
3379    extern char userspool[];     /* user spool directory */
3380  
3381 -  snprintf(MAXS(file),"%s/%d.d",userspool,flp->id);
3382 +  snprintf(file,sizeof(file)-1,"%s/%d.d",userspool,flp->id);
3383    unlink(file);
3384 -  snprintf(MAXS(file),"%s/%d.h",userspool,flp->id);
3385 +  snprintf(file,sizeof(file)-1,"%s/%d.h",userspool,flp->id);
3386    utf2iso(1,NULL,fname,NULL,flp->fname);
3387    if(unlink(file)<0) {
3388      if (client) {
3389 -      snprintf(MAXS(msg),"cannot delete spoolfile #%d",flp->id);
3390 +      snprintf(msg,sizeof(msg)-1,"cannot delete spoolfile #%d",flp->id);
3391        message("",'W',msg);
3392      }
3393      return(-1);
3394    } else {
3395      if (verbose) {
3396 -      snprintf(MAXS(msg),"%s deleted",fname);
3397 +      snprintf(msg,sizeof(msg)-1,"%s deleted",fname);
3398        message("",'I',msg);
3399      }
3400      return(0);
3401 @@ -874,7 +874,7 @@ int spoolid(int maxfiles) {
3402      if (n>maxfiles) return(-n);
3403  
3404      /* try to create header spool file */
3405 -    snprintf(MAXS(file),"%d.h",id);
3406 +    snprintf(file,sizeof(file)-1,"%d.h",id);
3407      fd=open(file,O_CREAT|O_EXCL,S_IRUSR|S_IWUSR);
3408  
3409      /* successfull? */
3410 @@ -883,7 +883,7 @@ int spoolid(int maxfiles) {
3411        close(fd);
3412  
3413        /* create data spool file */
3414 -      snprintf(MAXS(file),"%d.d",id);
3415 +      snprintf(file,sizeof(file)-1,"%d.d",id);
3416        close(open(file,O_CREAT|O_LARGEFILE,S_IRUSR|S_IWUSR));
3417  
3418        return(id);