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'
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.
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')
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'
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
38 plist_path.write startup_plist
42 def caveats; <<-EOCAVEATS
43 # Start/Stop sendfiled(8) Daemon
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!
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}
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}
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">
67 <string>#{plist_name}</string>
68 <key>ProgramArguments</key>
70 <string>#{HOMEBREW_PREFIX}/sbin/sendfiled</string>
74 <key>inetdCompatibility</key>
83 <key>SockServiceName</key>
87 <key>WorkingDirectory</key>
88 <string>#{HOMEBREW_PREFIX}</string>
98 src/address.c | 66 ++++++++--------
99 src/fetchfile.c | 126 ++++++++++++++--------------
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(-)
109 diff --git a/src/address.c b/src/address.c
110 index 4c75028..dcf6cd1 100644
113 @@ -134,15 +134,15 @@ void destination(int argc, char **argv,
114 snprintf(user,FLEN-1,"%s %s",pwe->pw_name,gecos);
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);
124 /* trick: argc == 0, when message reply mode */
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);
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) {
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) {
147 @@ -342,7 +342,7 @@ int check_forward(int sockfd, char *recipient, char *host, char *redirect) {
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);
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);
165 @@ -417,7 +417,7 @@ int saft_connect(const char *type,
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);
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")) {
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);
183 /* try generic saft-address for this host/domain */
185 - snprintf(MAXS(ahost),"saft.%s",host);
186 + snprintf(ahost,sizeof(ahost)-1,"saft.%s",host);
188 if(gethostbyname(ahost)){
190 @@ -446,7 +446,7 @@ int saft_connect(const char *type,
191 if (tolower(*answer)!='n' || !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);
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")) {
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",
206 message(prg,'E',tmp);
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,
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);
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;
237 @@ -500,9 +500,9 @@ int saft_connect(const char *type,
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);
248 /* is there a forward set? */
249 @@ -659,7 +659,7 @@ int saft_connect(const char *type,
251 if ((cp=strchr(host,':'))) *cp=0;
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);
258 @@ -671,7 +671,7 @@ int saft_connect(const char *type,
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);
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")) {
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);
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);
281 sockfd=open_connection(host,service);
283 @@ -701,7 +701,7 @@ int saft_connect(const char *type,
284 if (tolower(*answer)!='n' || !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);
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")) {
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",
299 message(prg,'E',tmp);
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,
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");
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;
333 @@ -763,9 +763,9 @@ int saft_connect(const char *type,
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);
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);
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);
368 /* scan the command line on options */
369 @@ -303,7 +303,7 @@ int main(int argc, char *argv[]) {
370 /* check tmp files */
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);
378 @@ -332,19 +332,19 @@ int main(int argc, char *argv[]) {
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);
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);
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)) {
403 @@ -386,24 +386,24 @@ int main(int argc, char *argv[]) {
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);
410 /* initiate the connection to the server */
413 message(prg,'F',"no SAFT server is defined");
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);
421 sockfd=open_connection(server,SERVICE);
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");
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")) {
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);
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")) {
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);
454 if (!str_beq(line,"331")) {
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);
461 @@ -440,7 +440,7 @@ int main(int argc, char *argv[]) {
462 outf=rfopen(pgptmp,"w");
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);
469 fprintf(outf,"%s",cp+1);
470 @@ -448,13 +448,13 @@ int main(int argc, char *argv[]) {
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);
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[]) {
489 iso2utf(tmp,response);
490 - snprintf(MAXS(response),"AUTH %s",tmp);
491 + snprintf(response,sizeof(response)-1,"AUTH %s",tmp);
492 sendheader(sockfd,response);
494 /* config file transfer? */
495 @@ -492,7 +492,7 @@ int main(int argc, char *argv[]) {
497 strcpy(conffile,tmp);
499 - snprintf(MAXS(conffile),"%s/%s",swd,tmp);
500 + snprintf(conffile,sizeof(conffile)-1,"%s/%s",swd,tmp);
502 /* write config file */
504 @@ -501,23 +501,23 @@ int main(int argc, char *argv[]) {
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 ")) {
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);
519 inf=rfopen(conffile,"r");
521 - snprintf(MAXS(tmp),"cannot open %s",conffile);
522 + snprintf(tmp,sizeof(tmp)-1,"cannot open %s",conffile);
523 message(prg,'F',tmp);
527 - snprintf(MAXS(tmp),"transfering %s",conffile);
528 + snprintf(tmp,sizeof(tmp)-1,"transfering %s",conffile);
529 message(prg,'I',tmp);
532 @@ -532,7 +532,7 @@ int main(int argc, char *argv[]) {
533 sock_getline(sockfd,line);
534 if (!str_beq(line,"201 ")) {
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);
541 @@ -542,12 +542,12 @@ int main(int argc, char *argv[]) {
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")) {
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);
555 if (str_beq("250 ",line)) break;
556 @@ -592,11 +592,11 @@ int main(int argc, char *argv[]) {
557 number=atoi(argv[i]);
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);
563 message(prg,'E',prg);
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);
570 @@ -616,7 +616,7 @@ int main(int argc, char *argv[]) {
571 get_list(sockfd,server,id,listf);
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);
579 @@ -624,7 +624,7 @@ int main(int argc, char *argv[]) {
581 listf=rfopen(listfile,"r");
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);
587 while (fgetl(line,listf)) {
588 @@ -642,11 +642,11 @@ int main(int argc, char *argv[]) {
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);
595 message(prg,'E',prg);
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);
602 @@ -666,7 +666,7 @@ int main(int argc, char *argv[]) {
603 for (i=optind;i<argc;i++) {
604 listf=rfopen(listfile,"r");
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);
610 while (fgetl(line,listf)) {
611 @@ -683,11 +683,11 @@ int main(int argc, char *argv[]) {
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);
618 message(prg,'E',prg);
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);
625 @@ -751,7 +751,7 @@ void rexit(int n) {
627 /* change back to starting directory */
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);
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 */
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);
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")) {
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);
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");
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");
665 - snprintf(MAXS(tmp),"GET HEADER %d",number);
666 + snprintf(tmp,sizeof(tmp)-1,"GET HEADER %d",number);
667 sock_putline(sockfd,tmp);
670 @@ -981,7 +981,7 @@ int get_file(int sockfd, int number, int ptso) {
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);
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,' '))) {
683 - snprintf(MAXS(tmp),"%s (%s)",line+9,cp+1);
684 + snprintf(tmp,sizeof(tmp)-1,"%s (%s)",line+9,cp+1);
688 @@ -1050,15 +1050,15 @@ int get_file(int sockfd, int number, int ptso) {
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);
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);
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);
707 @@ -1072,7 +1072,7 @@ int get_file(int sockfd, int number, int ptso) {
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);
716 @@ -1084,7 +1084,7 @@ int get_file(int sockfd, int number, int ptso) {
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);
725 @@ -1096,7 +1096,7 @@ int get_file(int sockfd, int number, int ptso) {
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);
734 @@ -1154,10 +1154,10 @@ int get_file(int sockfd, int number, int ptso) {
738 - snprintf(MAXS(tmp),
739 + snprintf(tmp,sizeof(tmp)-1,
740 "transfer of %s completed: %.1f kB/s",fname,thruput/1024);
742 - snprintf(MAXS(tmp),
743 + snprintf(tmp,sizeof(tmp)-1,
744 "transfer of %s completed: %d byte/s",fname,(int)thruput);
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);
759 if (*answer!='y' && *answer!='Y') {
760 @@ -1233,7 +1233,7 @@ void init() {
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);
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);
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
787 @@ -132,7 +132,7 @@ int fcopy(const char *from, const char *to, mode_t mode) {
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);
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);
800 - snprintf(MAXS(tmp),"error opening '%s'",from);
801 + snprintf(tmp,sizeof(tmp)-1,"error opening '%s'",from);
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);
809 - snprintf(MAXS(tmp),"error creating '%s'",to);
810 + snprintf(tmp,sizeof(tmp)-1,"error creating '%s'",to);
814 @@ -180,7 +180,7 @@ int fcopy(const char *from, const char *to, mode_t mode) {
818 - snprintf(MAXS(tmp),"error writing '%s'",to);
819 + snprintf(tmp,sizeof(tmp)-1,"error writing '%s'",to);
823 @@ -212,7 +212,7 @@ int fcopy(const char *from, const char *to, mode_t mode) {
827 - snprintf(MAXS(tmp),"error reading '%s'",from);
828 + snprintf(tmp,sizeof(tmp)-1,"error reading '%s'",from);
832 @@ -220,7 +220,7 @@ int fcopy(const char *from, const char *to, mode_t mode) {
833 /* count mismatch or read/write errors? */
836 - snprintf(MAXS(tmp),"wrong byte count for '%s'",from);
837 + snprintf(tmp,sizeof(tmp)-1,"wrong byte count for '%s'",from);
841 @@ -334,12 +334,12 @@ char *mktmpdir(int verbose) {
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);
851 - snprintf(MAXS(tmp),"directory for temporary files is: %s",tmpdir);
852 + snprintf(tmp,sizeof(tmp)-1,"directory for temporary files is: %s",tmpdir);
856 @@ -365,7 +365,7 @@ void rmtmpdir(char *tmpdir) {
858 if (chdir(tmpdir) < 0 || !(dp=opendir(tmpdir))) {
860 - snprintf(MAXS(tmp),"cleanup: cannot open %s",tmpdir);
861 + snprintf(tmp,sizeof(tmp)-1,"cleanup: cannot open %s",tmpdir);
865 @@ -378,7 +378,7 @@ void rmtmpdir(char *tmpdir) {
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);
874 @@ -386,7 +386,7 @@ void rmtmpdir(char *tmpdir) {
877 if (rmdir(tmpdir) < 0) {
878 - snprintf(MAXS(tmp),"cannot remove %s",tmpdir);
879 + snprintf(tmp,sizeof(tmp)-1,"cannot remove %s",tmpdir);
883 @@ -483,7 +483,7 @@ int vsystem(const char *cmd) {
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);
892 @@ -506,8 +506,8 @@ FILE* vpopen(const char *cmd, const char *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;
901 message(prg,'I',tmp);
903 diff --git a/src/net.c b/src/net.c
904 index eed63ac..64fcbcf 100644
907 @@ -458,7 +458,7 @@ int sock_getline(int fd, char *line) {
908 if (n+1==MAXLEN && line[n] != '\n') {
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);
914 message("",'F',line);
916 @@ -530,7 +530,7 @@ char *getreply(int fd) {
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);
925 @@ -542,7 +542,7 @@ char *getreply(int fd) {
926 /* reply message too short? */
929 - snprintf(MAXS(msg),"corrupt reply: \"%s\"",reply);
930 + snprintf(msg,sizeof(msg)-1,"corrupt reply: \"%s\"",reply);
934 @@ -565,7 +565,7 @@ char *getreply(int fd) {
935 /* fatal server error? */
938 - snprintf(MAXS(msg),"server error: %s",&reply[4]);
939 + snprintf(msg,sizeof(msg)-1,"server error: %s",&reply[4]);
943 @@ -640,7 +640,7 @@ int sendheader(int fd, char *line) {
944 if (str_beq(reply,"202")) return(1);
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);
952 @@ -725,7 +725,7 @@ int send_data(int sockfd, off_t size, const char *file,
953 if (!str_beq(reply,"230 ")) {
956 - snprintf(MAXS(tmp),"server error: %s",&reply[4]);
957 + snprintf(tmp,sizeof(tmp)-1,"server error: %s",&reply[4]);
961 @@ -742,7 +742,7 @@ int send_data(int sockfd, off_t size, const char *file,
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);
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 ")) {
974 - snprintf(MAXS(tmp),"corrupt server reply: %s",&reply[4]);
975 + snprintf(tmp,sizeof(tmp)-1,"corrupt server reply: %s",&reply[4]);
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) {
983 - snprintf(MAXS(tmp),"error reading %s",iso_name);
984 + snprintf(tmp,sizeof(tmp)-1,"error reading %s",iso_name);
988 @@ -775,12 +775,12 @@ int send_data(int sockfd, off_t size, const char *file,
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);
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);
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) {
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);
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) {
1016 - snprintf(MAXS(tmp),"error reading %s",iso_name);
1017 + snprintf(tmp,sizeof(tmp)-1,"error reading %s",iso_name);
1018 message("",'E',tmp);
1021 @@ -882,10 +882,10 @@ int send_data(int sockfd, off_t size, const char *file,
1025 - snprintf(MAXS(tmp),
1026 + snprintf(tmp,sizeof(tmp)-1,
1027 "transfer of %s completed: %.1f kB/s",fname,thruput/1024);
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);
1034 @@ -909,7 +909,7 @@ int send_data(int sockfd, off_t size, const char *file,
1036 if (sockfd && !str_beq(getreply(sockfd),"201 ")) {
1038 - snprintf(MAXS(tmp),"transfer failed for %s",iso_name);
1039 + snprintf(tmp,sizeof(tmp)-1,"transfer failed for %s",iso_name);
1041 message("",'E',tmp);
1043 diff --git a/src/receive.c b/src/receive.c
1044 index 50ae63e..96501b1 100644
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"");
1063 @@ -318,18 +318,18 @@ int main(int argc, char *argv[]) {
1064 /* determine the spool directory */
1066 if ((cp=getenv("SF_SPOOL"))) {
1067 - snprintf(MAXS(userspool),"%s",cp);
1068 + snprintf(userspool,sizeof(userspool)-1,"%s",cp);
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);
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);
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);
1085 message(prg,'E',tmp);
1087 @@ -337,7 +337,7 @@ int main(int argc, char *argv[]) {
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)",
1096 @@ -348,7 +348,7 @@ int main(int argc, char *argv[]) {
1097 /* are there any files to receive? */
1098 sls=scanspool(from);
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);
1105 @@ -359,7 +359,7 @@ int main(int argc, char *argv[]) {
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");
1114 @@ -420,15 +420,15 @@ int main(int argc, char *argv[]) {
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);
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);
1134 @@ -456,10 +456,10 @@ int main(int argc, char *argv[]) {
1138 - snprintf(MAXS(tmp),"%s %d",bouncelist,id);
1139 + snprintf(tmp,sizeof(tmp)-1,"%s %d",bouncelist,id);
1140 strcpy(bouncelist,tmp);
1142 - snprintf(MAXS(bouncelist),"%d",id);
1143 + snprintf(bouncelist,sizeof(bouncelist)-1,"%d",id);
1146 receive_sf(flp,pgpring,header);
1147 @@ -473,7 +473,7 @@ int main(int argc, char *argv[]) {
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);
1156 @@ -509,10 +509,10 @@ int main(int argc, char *argv[]) {
1160 - snprintf(MAXS(tmp),"%s %d",bouncelist,flp->id);
1161 + snprintf(tmp,sizeof(tmp)-1,"%s %d",bouncelist,flp->id);
1162 strcpy(bouncelist,tmp);
1164 - snprintf(MAXS(bouncelist),"%d",flp->id);
1165 + snprintf(bouncelist,sizeof(bouncelist)-1,"%d",flp->id);
1167 receive_sf(flp,pgpring,header);
1169 @@ -524,7 +524,7 @@ int main(int argc, char *argv[]) {
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);
1178 @@ -537,10 +537,10 @@ int main(int argc, char *argv[]) {
1179 /* files to bounce? */
1180 if (*bounce && *bouncelist) {
1182 - snprintf(MAXS(tmp),
1183 + snprintf(tmp,sizeof(tmp)-1,
1184 "sendfile -bk=y %s %s %s",opt_v,bouncelist,bounce);
1186 - snprintf(MAXS(tmp),
1187 + snprintf(tmp,sizeof(tmp)-1,
1188 "sendfile -bk=n %s %s %s",opt_v,bouncelist,bounce);
1191 @@ -668,17 +668,17 @@ int list(struct senderlist *sls, int format, char *from, char *pgpring,
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);
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);
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);
1212 /* sneak inside... */
1213 @@ -760,16 +760,16 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1215 switch (check_signature(flp,pgpring,0)) {
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);
1220 message(prg,'E',tmp);
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);
1226 message(prg,'E',tmp);
1228 - case -2: snprintf(MAXS(tmp),"bad signature for '%s'",nname);
1229 + case -2: snprintf(tmp,sizeof(tmp)-1,"bad signature for '%s'",nname);
1231 message(prg,'E',tmp);
1233 @@ -785,7 +785,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1235 /* show only the 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) {
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) {
1250 - snprintf(MAXS(tmp),"cannot decrypt '%s' :",nname);
1251 + snprintf(tmp,sizeof(tmp)-1,"cannot decrypt '%s' :",nname);
1252 message(prg,'E',tmp);
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);
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)) {
1266 - snprintf(MAXS(tmp),"cannot decompress '%s' :",nname);
1267 + snprintf(tmp,sizeof(tmp)-1,"cannot decompress '%s' :",nname);
1268 message(prg,'E',tmp);
1271 @@ -823,10 +823,10 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1272 else /* copy spool file to stdout */ {
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) {
1279 - snprintf(MAXS(tmp),"cannot read '%s'",nname);
1280 + snprintf(tmp,sizeof(tmp)-1,"cannot read '%s'",nname);
1281 message(prg,'E',tmp);
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;
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);
1294 message(prg,'E',tmp);
1296 @@ -877,7 +877,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1297 create_sigfile(flp->sign,fname,nname,&overwrite);
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);
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) {
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);
1313 /* create temporary decrypted tar file */
1315 if (stat(tartmp,&finfo)<0 || finfo.st_size==0) {
1317 - snprintf(MAXS(tmp),"cannot decrypt '%s' :",nname);
1318 + snprintf(tmp,sizeof(tmp)-1,"cannot decrypt '%s' :",nname);
1319 message(prg,'E',tmp);
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);
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);
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);
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);
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);
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);
1361 /* open pipe to read tar file-info */
1362 @@ -1016,21 +1016,21 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
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);
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);
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);
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);
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)) {
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);
1398 @@ -1055,7 +1055,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1400 /* was there an error with tar? */
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);
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 */
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);
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) {
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);
1426 message(prg,'E',tmp);
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) {
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);
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);
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);
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"))) {
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);
1478 @@ -1192,12 +1192,12 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1480 } else /* binary format */ {
1482 - snprintf(MAXS(sfile),"%s/%d.d",userspool,flp->id);
1483 + snprintf(sfile,sizeof(sfile)-1,"%s/%d.d",userspool,flp->id);
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);
1493 @@ -1215,16 +1215,16 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
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);
1502 - snprintf(MAXS(tmp),"call to %s failed, cannot receive '%s'",
1503 + snprintf(tmp,sizeof(tmp)-1,"call to %s failed, cannot receive '%s'",
1505 message(prg,'E',tmp);
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);
1514 @@ -1239,7 +1239,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1516 if (spawn(sad,fname,cmask)<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);
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) {
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) {
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);
1536 @@ -1274,7 +1274,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1537 !(flp->flags&F_CRYPT)) {
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");
1545 @@ -1282,7 +1282,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
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);
1554 @@ -1298,9 +1298,9 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1555 } else /* binary 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);
1564 message(prg,'E',tmp);
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);
1570 - snprintf(MAXS(tmp),"'%s' received",nname);
1571 + snprintf(tmp,sizeof(tmp)-1,"'%s' received",nname);
1572 message(prg,'I',tmp);
1574 /* foreign character set in text file? */
1575 if ((flp->flags&F_TEXT) && !str_eq(flp->charset,CHARSET)) {
1577 /* call GNU recode */
1578 - snprintf(MAXS(tmp),"%s:"CHARSET,flp->charset);
1579 + snprintf(tmp,sizeof(tmp)-1,"%s:"CHARSET,flp->charset);
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'",
1589 message(prg,'E',tmp);
1590 @@ -1348,7 +1348,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1592 /* metamail call allowed? */
1594 - snprintf(MAXS(tmp),
1595 + snprintf(tmp,sizeof(tmp)-1,
1596 "'%s' is a MIME file, you have to run it through metamail",
1598 message(prg,'I',tmp);
1599 @@ -1360,7 +1360,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
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) {
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);
1617 @@ -1415,7 +1415,7 @@ void crlf2lf(FILE *inf, FILE *outf, const char *fname, const char *nname) {
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);
1626 @@ -1426,7 +1426,7 @@ void crlf2lf(FILE *inf, FILE *outf, const char *fname, const char *nname) {
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);
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);
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);
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 */
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);
1654 message(prg,'E',tmp);
1655 @@ -1649,14 +1649,14 @@ int create_sigfile(const char *sign, const char *fname, const char *nname,
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);
1665 fprintf(outf,"%s",sign);
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);
1672 @@ -1695,9 +1695,9 @@ int check_signature(struct filelist *flp, char *pgpring, int print) {
1673 if (str_eq(pgpring,".")) *pgpring=0;
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);
1684 @@ -1707,15 +1707,15 @@ int check_signature(struct filelist *flp, char *pgpring, int print) {
1685 /* build pgp options */
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);
1692 - snprintf(MAXS(pgpopt),"+batchmode=on +language=en +pubring=%s",pgpring);
1693 + snprintf(pgpopt,sizeof(pgpopt)-1,"+batchmode=on +language=en +pubring=%s",pgpring);
1695 - snprintf(MAXS(pgpopt),"+batchmode=on +language=en");
1696 + snprintf(pgpopt,sizeof(pgpopt)-1,"+batchmode=on +language=en");
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");
1704 @@ -1789,7 +1789,7 @@ void renumber (struct senderlist *sls) {
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);
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;
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) {
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);
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);
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);
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;
1748 - snprintf(MAXS(tmp),"unsupported compression program %s",force_compress);
1749 + snprintf(tmp,sizeof(tmp)-1,"unsupported compression program %s",force_compress);
1751 message(prg,'F',tmp);
1753 @@ -660,7 +660,7 @@ const char
1754 } else if (*compress) {
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
1764 if (!*zprg) *bzip2_bin=0;
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;
1771 @@ -719,7 +719,7 @@ const char
1772 if (str_eq(host,"127.0.0.1") || str_eq(host,"0")) strcpy(host,localhost);
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++) {
1779 strcat(cmd,argv[i]);
1780 @@ -764,7 +764,7 @@ const char
1784 - snprintf(MAXS(pgprid),"%s@%s",recipient,host);
1785 + snprintf(pgprid,sizeof(pgprid)-1,"%s@%s",recipient,host);
1787 /* is there a recipient id? */
1789 @@ -796,7 +796,7 @@ const char
1790 /* is there a signature id? */
1792 if (*pop=='=') pop++;
1793 - snprintf(MAXS(pgpsign),"-u '%s",pop);
1794 + snprintf(pgpsign,sizeof(pgpsign)-1,"-u '%s",pop);
1796 /* cut off any more options */
1797 if ((cp=strchr(pgpsign,'\n'))) {
1798 @@ -813,7 +813,7 @@ const char
1800 /* wrong pgp options */
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);
1807 @@ -821,13 +821,13 @@ const char
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);
1826 /* where are the files/directories ? */
1828 @@ -845,11 +845,11 @@ const char
1830 printf("%s\n",userspool);
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);
1837 - snprintf(MAXS(tmp),"%s is an unknown -W argument",where);
1838 + snprintf(tmp,sizeof(tmp)-1,"%s is an unknown -W argument",where);
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
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);
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);
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);
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);
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);
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);
1884 @@ -970,14 +970,14 @@ const char
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);
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);
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);
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)",
1916 message(prg,'F',tmp);
1917 @@ -1045,19 +1045,19 @@ const char
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);
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);
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);
1942 @@ -1091,7 +1091,7 @@ const char
1943 strcpy(comment,strchr(line,' ')+1);
1944 if ((cp=strchr(comment,' '))) {
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);
1951 @@ -1129,7 +1129,7 @@ const char
1952 if (str_beq(reply,"200 ")) break;
1955 - snprintf(MAXS(tmp),"cannot send %s : %s",file,reply+4);
1956 + snprintf(tmp,sizeof(tmp)-1,"cannot send %s : %s",file,reply+4);
1958 message(prg,'E',tmp);
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);
1967 - snprintf(MAXS(cmd),"%s -d < %s > %s",BZIP2,sdfn,ziptmp);
1968 + snprintf(cmd,sizeof(cmd)-1,"%s -d < %s > %s",BZIP2,sdfn,ziptmp);
1970 - snprintf(MAXS(cmd),"%s -dc %s > %s",GZIP,sdfn,ziptmp);
1971 + snprintf(cmd,sizeof(cmd)-1,"%s -dc %s > %s",GZIP,sdfn,ziptmp);
1973 /* execute shell-command and close spool header file on error */
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);
1980 @@ -1169,9 +1169,9 @@ const char
1981 /* is there already a comment line? */
1982 if (str_beq(line,"COMMENT")) {
1984 - snprintf(MAXS(line),"%s+AA0ACg-%s",comment,redirect);
1985 + snprintf(line,sizeof(line)-1,"%s+AA0ACg-%s",comment,redirect);
1987 - snprintf(MAXS(tmp),
1988 + snprintf(tmp,sizeof(tmp)-1,
1989 "%s+AA0ACg-forward+ACA-from+ACA-%s",line,comment);
1992 @@ -1200,9 +1200,9 @@ const char
1993 /* send comment if not already done */
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);
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);
2004 @@ -1215,12 +1215,12 @@ const char
2005 /* check the file size */
2006 if (stat(ziptmp,&finfo)==0) {
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);
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]);
2019 message(prg,'E',tmp);
2020 @@ -1302,7 +1302,7 @@ const char
2024 - snprintf(MAXS(tmp),"shell-call: %s",cmd);
2025 + snprintf(tmp,sizeof(tmp)-1,"shell-call: %s",cmd);
2026 message(prg,'I',tmp);
2029 @@ -1331,9 +1331,9 @@ const char
2030 /* compress tar-archive */
2031 if (!quiet) printf("compressing... \r");
2033 - snprintf(MAXS(cmd),"%s < %s > %s",zprg,tartmp,ziptmp);
2034 + snprintf(cmd,sizeof(cmd)-1,"%s < %s > %s",zprg,tartmp,ziptmp);
2036 - snprintf(MAXS(tmp),"shell-call: %s",cmd);
2037 + snprintf(tmp,sizeof(tmp)-1,"shell-call: %s",cmd);
2038 message(prg,'I',tmp);
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");
2045 - snprintf(MAXS(sizes),"%lld %lld",size,orgsize);
2046 + snprintf(sizes,sizeof(sizes)-1,"%lld %lld",size,orgsize);
2048 /* write to outgoing spool? */
2050 @@ -1360,9 +1360,9 @@ const char
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]);
2057 - snprintf(MAXS(to),"%s@%s",recipient,host);
2058 + snprintf(to,sizeof(to)-1,"%s@%s",recipient,host);
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)) {
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
2073 } else { /* send header lines */
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 */
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);
2089 @@ -1424,14 +1424,14 @@ const char
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);
2098 if (str_eq(compress,S_GZIP))
2099 - snprintf(MAXS(tmp),"TYPE BINARY COMPRESSED");
2100 + snprintf(tmp,sizeof(tmp)-1,"TYPE BINARY COMPRESSED");
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) {
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");
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);
2120 - snprintf(MAXS(tmp),"%s\r\n%s",line,redirect);
2121 + snprintf(tmp,sizeof(tmp)-1,"%s\r\n%s",line,redirect);
2124 strcpy(line,redirect);
2125 @@ -1472,7 +1472,7 @@ const char
2127 fprintf(oshf,"COMMENT\t%s\n",tmp);
2129 - snprintf(MAXS(line),"COMMENT %s",tmp);
2130 + snprintf(line,sizeof(line)-1,"COMMENT %s",tmp);
2131 sendcommand(sockfd,line,NULL);
2134 @@ -1515,7 +1515,7 @@ const char
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);
2141 /* file from stdin? */
2143 @@ -1549,9 +1549,9 @@ const char
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]);
2150 - snprintf(MAXS(to),"%s@%s",recipient,host);
2151 + snprintf(to,sizeof(to)-1,"%s@%s",recipient,host);
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)) {
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
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 ",
2172 if (quiet<2) message(prg,'I',tmp);
2173 @@ -1595,7 +1595,7 @@ const char
2174 } else /* send header lines */ {
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");
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);
2191 @@ -1616,7 +1616,7 @@ const char
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);
2200 @@ -1628,7 +1628,7 @@ const char
2201 /* is it a regular file? */
2202 if (!S_ISREG(finfo.st_mode)) {
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);
2209 @@ -1659,7 +1659,7 @@ const char
2210 inf=rfopen(file,"r");
2211 outf=rfopen(texttmp,"w");
2213 - snprintf(MAXS(tmp),"cannot open '%s'",file);
2214 + snprintf(tmp,sizeof(tmp)-1,"cannot open '%s'",file);
2215 message(prg,'E',tmp);
2218 @@ -1703,7 +1703,7 @@ const char
2219 for (n=0;do_compress && *cft[n];n++) {
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;
2227 @@ -1715,13 +1715,13 @@ const char
2228 /* compress tmp-file */
2229 if (!quiet) printf("compressing... \r");
2231 - snprintf(MAXS(cmd),"%s < '%s' > %s",zprg,file,ziptmp);
2232 + snprintf(cmd,sizeof(cmd)-1,"%s < '%s' > %s",zprg,file,ziptmp);
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);
2239 - snprintf(MAXS(tmp),"cannot compress %s",file);
2240 + snprintf(tmp,sizeof(tmp)-1,"cannot compress %s",file);
2241 message(prg,'E',tmp);
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");
2248 - snprintf(MAXS(sizes),"%lld %lld",size,orgsize);
2249 + snprintf(sizes,sizeof(sizes)-1,"%lld %lld",size,orgsize);
2251 printf("DEBUG: size=%lld orgsize=%lld sizes=%s\n",size,orgsize,sizes);
2253 @@ -1781,22 +1781,22 @@ const char
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);
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);
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) {
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);
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");
2283 @@ -1811,7 +1811,7 @@ const char
2284 if (*comment) strcat(line,comment);
2287 - snprintf(MAXS(tmp),"%s\r\n%s",line,redirect);
2288 + snprintf(tmp,sizeof(tmp)-1,"%s\r\n%s",line,redirect);
2291 strcpy(line,redirect);
2292 @@ -1820,7 +1820,7 @@ const char
2294 fprintf(oshf,"COMMENT\t%s\n",tmp);
2296 - snprintf(MAXS(line),"COMMENT %s",tmp);
2297 + snprintf(line,sizeof(line)-1,"COMMENT %s",tmp);
2298 sendcommand(sockfd,line,NULL);
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);
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);
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);
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);
2322 @@ -1952,7 +1952,7 @@ void cleanup() {
2323 if (str_beq(reply,"220 ") && strstr(reply,"SAFT")) {
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);
2331 @@ -1981,7 +1981,7 @@ void cleanup() {
2332 if (str_beq(reply,"220 ") && strstr(reply,"SAFT")) {
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);
2340 @@ -2033,7 +2033,7 @@ void pgp_encrypt(int pgpcrypt, char *pgprid, char *file) {
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);
2347 if (stat(pgptmp,&finfo)<0 || finfo.st_size==0 || !(inf=rfopen(pgptmp,"r"))) {
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")) {
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) {
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) {
2367 @@ -2067,7 +2067,7 @@ void pgp_encrypt(int pgpcrypt, char *pgprid, char *file) {
2369 /* pgp needs no user input */
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) {
2376 @@ -2102,10 +2102,10 @@ void pgp_sign(const char *pgpsign, const char *infile, int sockfd) {
2378 if (!quiet && !pgppass) message(prg,'I',"call to pgp...");
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));
2384 - snprintf(MAXS(tmp),"shell-call: %s",cmd);
2385 + snprintf(tmp,sizeof(tmp)-1,"shell-call: %s",cmd);
2386 message(prg,'I',tmp);
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");
2393 - snprintf(MAXS(sign),"SIGN %s",tmp);
2394 + snprintf(sign,sizeof(sign)-1,"SIGN %s",tmp);
2395 if (sockfd) sendcommand(sockfd,sign,NULL);
2398 @@ -2197,13 +2197,13 @@ void start_spooldaemon(char *localhost) {
2400 sockfd=open_connection(localhost,SERVICE);
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");
2416 @@ -2215,10 +2215,10 @@ void start_spooldaemon(char *localhost) {
2417 if (!str_beq(line,"220 ") || !strstr(line,"SAFT")) {
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);
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);
2428 message(prg,'F',tmp);
2429 @@ -2241,13 +2241,13 @@ void start_spooldaemon(char *localhost) {
2431 sockfd=open_connection(host,SERVICE);
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");
2447 @@ -2259,10 +2259,10 @@ void start_spooldaemon(char *localhost) {
2448 if (!str_beq(line,"220 ") || !strstr(line,"SAFT")) {
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);
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);
2459 message(prg,'F',tmp);
2460 @@ -2392,7 +2392,7 @@ void get_header(const char *cmd, char *arg){
2461 if (!str_eq(cmd,line)) {
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);
2469 @@ -2473,7 +2473,7 @@ char guess_ftype(const char *file, char *type) {
2470 /* next, try with file command */
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)) {
2478 @@ -2485,7 +2485,7 @@ char guess_ftype(const char *file, char *type) {
2479 if ((cp=strchr(type,'\n'))) *cp=0;
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);
2487 @@ -2535,14 +2535,14 @@ int linkspeed(const char *host, int lanspeed, char **compress) {
2488 if (lanspeed<1) return(1);
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)) {
2495 if (mkdir(speeddir,S_IRUSR|S_IWUSR|S_IXUSR)<0) return(1);
2496 chmod(speeddir,S_IRUSR|S_IWUSR|S_IXUSR);
2499 - snprintf(MAXS(hostfile),"%s/%s",speeddir,host);
2500 + snprintf(hostfile,sizeof(hostfile)-1,"%s/%s",speeddir,host);
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);
2508 - snprintf(MAXS(msg),
2509 + snprintf(msg,sizeof(msg)-1,
2510 "disabling compressing because last link speed to %s was %d kB/s",
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);
2518 @@ -2587,14 +2587,14 @@ void notespeed(const char *host, unsigned long size, float ttime) {
2519 if (ttime<1 || size<102400) return;
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)) {
2526 if (mkdir(speeddir,S_IRUSR|S_IWUSR|S_IXUSR)<0) return;
2527 chmod(speeddir,S_IRUSR|S_IWUSR|S_IXUSR);
2530 - snprintf(MAXS(hostfile),"%s/%s",speeddir,host);
2531 + snprintf(hostfile,sizeof(hostfile)-1,"%s/%s",speeddir,host);
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;
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);
2544 @@ -2666,9 +2666,9 @@ void spooled_info(const char *file, const char *sdf, int compressed) {
2545 size=(finfo.st_size+512)/1024;
2548 - snprintf(MAXS(tmp),"'%s' spooled (%d KB [compressed])",file,size);
2549 + snprintf(tmp,sizeof(tmp)-1,"'%s' spooled (%d KB [compressed])",file,size);
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);
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[]) {
2562 if (str_eq(line,"path")) {
2564 - snprintf(MAXS(path),"PATH=%s",argp);
2565 + snprintf(path,sizeof(path)-1,"PATH=%s",argp);
2569 @@ -665,7 +665,7 @@ int main(int argc, char *argv[]) {
2572 if (str_eq(line,"forcepgp")) {
2573 - snprintf(MAXS(sys_forcepgp),"%s",argp);
2574 + snprintf(sys_forcepgp,sizeof(sys_forcepgp)-1,"%s",argp);
2577 if (str_eq(line,"spooling")) {
2578 @@ -896,7 +896,7 @@ int main(int argc, char *argv[]) {
2579 strcpy(forcepgp,sys_forcepgp);
2581 /* parse the user config-file */
2582 - snprintf(MAXS(tmp),"%s/config",userconfig);
2583 + snprintf(tmp,sizeof(tmp)-1,"%s/config",userconfig);
2585 if ((inf=rfopen(tmp,"r"))) {
2586 while ((fgetl(line,inf))) {
2587 @@ -935,7 +935,7 @@ int main(int argc, char *argv[]) {
2589 /* pgp force option */
2590 if (str_eq(line,"forcepgp")) {
2591 - snprintf(MAXS(forcepgp),"%s",argp);
2592 + snprintf(forcepgp,sizeof(forcepgp)-1,"%s",argp);
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);
2604 /* mail address specified to send notifications to? */
2605 @@ -1038,18 +1038,18 @@ int main(int argc, char *argv[]) {
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,' '))) {
2616 - snprintf(MAXS(logsender),"%s (%s)",utfsender,cp+1);
2617 + snprintf(logsender,sizeof(logsender)-1,"%s (%s)",utfsender,cp+1);
2620 strcpy(logsender,utfsender);
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);
2629 @@ -1087,7 +1087,7 @@ int main(int argc, char *argv[]) {
2630 if ((cp=strchr(date,'T'))) *cp=' ';
2631 if (!strchr(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],
2638 @@ -1402,7 +1402,7 @@ int main(int argc, char *argv[]) {
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);
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"))) {
2655 if ((cp=strchr(tmp,' '))) *cp=0;
2656 @@ -1566,7 +1566,7 @@ int main(int argc, char *argv[]) {
2658 /* open spool data file for appending */
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(¬ify,notification,sender,recipient,
2665 @@ -1608,8 +1608,8 @@ int main(int argc, char *argv[]) {
2666 notify_reply(¬ify,notification,sender,recipient,mailto,bell,413);
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(¬ify,notification,sender,
2676 @@ -1734,7 +1734,7 @@ int main(int argc, char *argv[]) {
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",
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)) {
2693 /* number of bytes already transmitted */
2694 @@ -1931,14 +1931,14 @@ int main(int argc, char *argv[]) {
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);
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());
2709 outf=rfopen(csfile,"w");
2711 @@ -1954,7 +1954,7 @@ int main(int argc, char *argv[]) {
2712 * pgp -sbaf +clearsig=on +secring=private.pgp +pubring=private.pgp
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);
2720 @@ -2009,7 +2009,7 @@ int main(int argc, char *argv[]) {
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);
2728 /* change effective uid and gid to recipient */
2729 @@ -2138,7 +2138,7 @@ int main(int argc, char *argv[]) {
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);
2737 /* read and transfer header file */
2738 @@ -2163,7 +2163,7 @@ int main(int argc, char *argv[]) {
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) {
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 */
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);
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 */
2760 - snprintf(MAXS(msgcf),"%s/config/tty@%s",userspool,localhost);
2761 + snprintf(msgcf,sizeof(msgcf)-1,"%s/config/tty@%s",userspool,localhost);
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) {
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);
2772 - snprintf(MAXS(output),"\r\n%s\n\r",msgh);
2773 + snprintf(output,sizeof(output)-1,"\r\n%s\n\r",msgh);
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) {
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)) {
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)) {
2790 - snprintf(MAXS(tty),"/dev/%s",uinfo.ut_line);
2791 + snprintf(tty,sizeof(tty)-1,"/dev/%s",uinfo.ut_line);
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=' ';
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");
2803 /* fill out mail message */
2804 @@ -2730,7 +2730,7 @@ int restricted(const char *sender, const char *recipient, char type) {
2808 - snprintf(MAXS(killfile),"%s/config/restrictions",userspool);
2809 + snprintf(killfile,sizeof(killfile)-1,"%s/config/restrictions",userspool);
2812 /* open and check killfile */
2813 @@ -2786,9 +2786,9 @@ off_t free_space() {
2817 - snprintf(MAXS(spool),"%s/.",userspool);
2818 + snprintf(spool,sizeof(spool)-1,"%s/.",userspool);
2820 - snprintf(MAXS(spool),"%s/.",SPOOL);
2821 + snprintf(spool,sizeof(spool)-1,"%s/.",SPOOL);
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) {
2827 /* get maximum file size for this process */
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);
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) {
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);
2843 - snprintf(MAXS(user),"%s",to);
2844 + snprintf(user,sizeof(user)-1,"%s",to);
2845 strcpy(host,localhost);
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);
2852 - snprintf(MAXS(tmp),"connected to %s",host);
2853 + snprintf(tmp,sizeof(tmp)-1,"connected to %s",host);
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 ")) {
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 ")) {
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 ")) {
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));
2887 @@ -3022,16 +3022,16 @@ int sfsd(int queue, int parallel, int bounce, int retry, float mtp) {
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));
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));
2902 - snprintf(MAXS(tmp),"%d\n",(int)getpid());
2903 + snprintf(tmp,sizeof(tmp)-1,"%d\n",(int)getpid());
2904 write(lockf,tmp,strlen(tmp));
2906 /* disconnect from client */
2907 @@ -3079,7 +3079,7 @@ int sfsd(int queue, int parallel, int bounce, int retry, float mtp) {
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);
2916 @@ -3126,7 +3126,7 @@ int sfsd(int queue, int parallel, int bounce, int retry, float mtp) {
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) {
2929 - snprintf(MAXS(tmp),"connected to %s (forward redirection)",
2930 + snprintf(tmp,sizeof(tmp)-1,"connected to %s (forward redirection)",
2932 if (queue==1) message(prg,'I',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) {
2937 signal(SIGCHLD,sigchld);
2938 - snprintf(MAXS(tmp),"sleep %d s",ssec);
2939 + snprintf(tmp,sizeof(tmp)-1,"sleep %d s",ssec);
2943 @@ -3291,17 +3291,17 @@ int send_spooldata(int sockfd, char *oshfn, char *from, char *to,
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);
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);
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);
2964 @@ -3318,10 +3318,10 @@ int send_spooldata(int sockfd, char *oshfn, char *from, char *to,
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);
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++) {
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);
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);
2993 sockfd=open_connection(server,SAFT);
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);
2999 - snprintf(MAXS(tmp),"forward points to %s",host);
3000 + snprintf(tmp,sizeof(tmp)-1,"forward points to %s",host);
3004 @@ -3427,7 +3427,7 @@ int saftserver_connect(char *host, char *error) {
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);
3013 @@ -3477,14 +3477,14 @@ int saftserver_connect(char *host, char *error) {
3014 for (hopcount=1; hopcount<11; hopcount++) {
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);
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);
3029 sockfd=open_connection(server,SERVICE);
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);
3035 - snprintf(MAXS(tmp),"forward points to %s",host);
3036 + snprintf(tmp,sizeof(tmp)-1,"forward points to %s",host);
3040 @@ -3531,7 +3531,7 @@ int saftserver_connect(char *host, char *error) {
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);
3049 @@ -3576,7 +3576,7 @@ int mail_report(const char *host) {
3050 /* stupid NeXT has a broken readdir(); this is a dirty workaround */
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) {
3057 if (parallel) continue;
3058 @@ -3597,7 +3597,7 @@ int mail_report(const char *host) {
3059 while ((dire=readdir(dp))) {
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;
3066 mailf=rfopen(mailfn,"r");
3067 @@ -3693,7 +3693,7 @@ void check_outspool(int bounce) {
3068 while ((dire=readdir(dp))) {
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;
3076 @@ -3703,7 +3703,7 @@ void check_outspool(int bounce) {
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);
3085 @@ -3749,8 +3749,8 @@ int bounce_file(char *file, char *comment) {
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';
3095 if (stat(oshfn,&finfo)<0) return(-1);
3096 @@ -3758,7 +3758,7 @@ int bounce_file(char *file, char *comment) {
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);
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) {
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);
3114 if (!(outf=rfopen(shfn,"w"))) {
3116 @@ -3814,7 +3814,7 @@ int bounce_file(char *file, char *comment) {
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);
3123 fprintf(outf,"COMMENT\t%s\n",arg);
3125 @@ -3930,7 +3930,7 @@ int check_userspool(char *user, int userconfighome) {
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);
3133 if (fgetl(tmp,pp) && *tmp!='\n' && *tmp!=0) {
3134 @@ -3958,8 +3958,8 @@ int check_userspool(char *user, int userconfighome) {
3136 /* build user spool string */
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);
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
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());
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());
3168 @@ -4222,13 +4224,13 @@ int sudo(const char *user, const char *cmd) {
3169 if (setuid(pwe->pw_uid)<0) exit(1);
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);
3175 - snprintf(MAXS(tmp),"SHELL=%s",pwe->pw_shell);
3176 + snprintf(tmp,sizeof(tmp)-1,"SHELL=%s",pwe->pw_shell);
3178 - snprintf(MAXS(tmp),"USER=%s",user);
3179 + snprintf(tmp,sizeof(tmp)-1,"USER=%s",user);
3181 - snprintf(MAXS(tmp),"LOGNAME=%s",user);
3182 + snprintf(tmp,sizeof(tmp)-1,"LOGNAME=%s",user);
3186 diff --git a/src/sendmsg.c b/src/sendmsg.c
3187 index 23c60b1..2dd4318 100644
3190 @@ -260,10 +260,10 @@ int main(int argc, char *argv[]) {
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[]) {
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);
3210 /* open tty write permissions if necessary */
3212 @@ -293,14 +293,14 @@ int main(int argc, char *argv[]) {
3213 fprintf(outf,"%s\n",tty);
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) {
3221 "receiving messages is now restricted to this tty");
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);
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)) {
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);
3238 @@ -401,7 +401,7 @@ int main(int argc, char *argv[]) {
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);
3247 @@ -433,7 +433,7 @@ int main(int argc, char *argv[]) {
3248 iso2utf(utf_msg,iso_msg);
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);
3255 sr=getreply(sockfd);
3256 @@ -441,12 +441,12 @@ int main(int argc, char *argv[]) {
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);
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);
3271 diff --git a/src/spool.c b/src/spool.c
3272 index a1fdd8e..5f36085 100644
3275 @@ -181,7 +181,7 @@ struct senderlist *scanspool(char *sender) {
3276 /* mega stupid NeXT has broken readdir() */
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);
3283 /* scan through spool directory */
3284 @@ -216,7 +216,7 @@ struct senderlist *scanspool(char *sender) {
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");
3293 @@ -224,7 +224,7 @@ struct senderlist *scanspool(char *sender) {
3295 /* called from receive 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);
3302 @@ -246,9 +246,9 @@ struct senderlist *scanspool(char *sender) {
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);
3314 @@ -260,7 +260,7 @@ struct senderlist *scanspool(char *sender) {
3315 if (keep>0 && (ctime-rtime)/DAYSEC>=keep) {
3318 - snprintf(MAXS(file),"%s/%d.h",userspool,id);
3319 + snprintf(file,sizeof(file)-1,"%s/%d.h",userspool,id);
3323 @@ -293,7 +293,7 @@ struct senderlist *scanspool(char *sender) {
3324 if (str_eq(hline,"FROM")) {
3325 if ((cp=strchr(arg,' '))) {
3327 - snprintf(MAXS(tmp),"%s (%s)",arg,cp+1);
3328 + snprintf(tmp,sizeof(tmp)-1,"%s (%s)",arg,cp+1);
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);
3339 - snprintf(MAXS(file),"%s/%d.h",userspool,id);
3340 + snprintf(file,sizeof(file)-1,"%s/%d.h",userspool,id);
3344 @@ -539,7 +539,7 @@ struct hostlist *scanoutspool(char *sender) {
3345 /* mega stupid NeXT has broken readdir() */
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);
3352 /* scan through spool directory */
3353 @@ -561,18 +561,18 @@ struct hostlist *scanoutspool(char *sender) {
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;
3362 - snprintf(MAXS(hfn),OUTGOING"/%s",tmp);
3363 + snprintf(hfn,sizeof(hfn)-1,OUTGOING"/%s",tmp);
3365 /* open header file */
3366 if ((hf=rfopen(hfn,"r")) == NULL) {
3368 /* called from receive 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);
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 */
3379 - snprintf(MAXS(file),"%s/%d.d",userspool,flp->id);
3380 + snprintf(file,sizeof(file)-1,"%s/%d.d",userspool,flp->id);
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) {
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);
3394 - snprintf(MAXS(msg),"%s deleted",fname);
3395 + snprintf(msg,sizeof(msg)-1,"%s deleted",fname);
3396 message("",'I',msg);
3399 @@ -874,7 +874,7 @@ int spoolid(int maxfiles) {
3400 if (n>maxfiles) return(-n);
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);
3408 @@ -883,7 +883,7 @@ int spoolid(int maxfiles) {
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));