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