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'
10 # - remove nested "MAXS() inside snprintf()" macros.
11 # - disable wtmp/utmp on Mac OS X.
12 # - only call seteuid() & setegid() when it would change user/group.
17 inreplace ["makeconfig", "etc/sfdconf", "doc/receive.1", "doc/sendfile.1", "doc/sendmsg.1", "doc/sendfiled.8" ] do |s|
18 s.gsub! "/usr/local", "#{HOMEBREW_PREFIX}"
19 s.gsub! "/var/spool/sendfile", (var + 'spool/sendfile')
25 sbin.install 'src/sendfiled'
26 sbin.install 'etc/sfdconf'
27 bin.install 'src/fetchfile', 'src/receive', 'src/sendfile', 'src/sendmsg'
28 bin.install 'src/utf7encode', 'src/wlock'
29 bin.install 'etc/check_sendfile', 'etc/sfconf'
30 etc.install 'etc/sendfile.cf', 'etc/sendfile.deny'
31 man1.install 'doc/fetchfile.1', 'doc/receive.1', 'doc/sendfile.1', 'doc/sendmsg.1'
32 man1.install 'doc/utf7encode.1', 'doc/wlock.1'
33 man8.install 'doc/sendfiled.8'
35 (var + 'spool/sendfile/LOG').mkpath
36 (var + 'spool/sendfile/OUTGOING').mkpath
37 (var + 'spool/sendfile/LOG').chmod 00700
38 (var + 'spool/sendfile/OUTGOING').chmod 01777
40 plist_path.write startup_plist
44 def caveats; <<-EOCAVEATS
45 # Start/Stop sendfiled(8) Daemon
47 Note: if you only want to send file using sendfile(1) or messages using
48 sendmsg(1), and don't want to receive any files or messages at all, you
49 don't have to enable the sendfiled(8) server daemon!
51 If this is your first install, automatically load on login with:
52 sudo cp #{plist_path} /Library/LaunchDaemons/
53 sudo launchctl load -w /Library/LaunchDaemons/#{plist_path.basename}
55 If this is an upgrade and you already have the #{plist_path.basename} loaded:
56 sudo launchctl unload -w /Library/LaunchDaemons/#{plist_path.basename}
57 sudo cp #{plist_path} /Library/LaunchDaemons/
58 sudo launchctl load -w /Library/LaunchDaemons/#{plist_path.basename}
64 <?xml version="1.0" encoding="UTF-8"?>
65 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
69 <string>#{plist_name}</string>
70 <key>ProgramArguments</key>
72 <string>#{HOMEBREW_PREFIX}/sbin/sendfiled</string>
76 <key>inetdCompatibility</key>
85 <key>SockServiceName</key>
89 <key>WorkingDirectory</key>
90 <string>#{HOMEBREW_PREFIX}</string>
100 src/address.c | 66 ++++++++--------
101 src/fetchfile.c | 126 ++++++++++++++--------------
103 src/net.c | 32 ++++----
104 src/receive.c | 216 ++++++++++++++++++++++++------------------------
105 src/sendfile.c | 242 +++++++++++++++++++++++++++---------------------------
106 src/sendfiled.c | 180 +++++++++++++++++++++--------------------
107 src/sendmsg.c | 20 +++---
108 src/spool.c | 38 +++++-----
109 9 files changed, 475 insertions(+), 473 deletions(-)
111 diff --git a/src/address.c b/src/address.c
112 index 4c75028..dcf6cd1 100644
115 @@ -134,15 +134,15 @@ void destination(int argc, char **argv,
116 snprintf(user,FLEN-1,"%s %s",pwe->pw_name,gecos);
118 /* check user configuration directory */
119 - snprintf(MAXS(userconfig),"%s/.sendfile",pwe->pw_dir);
120 - snprintf(MAXS(tmp),SPOOL"/%s/config",pwe->pw_name);
121 + snprintf(userconfig,sizeof(userconfig)-1,"%s/.sendfile",pwe->pw_dir);
122 + snprintf(tmp,sizeof(tmp)-1,SPOOL"/%s/config",pwe->pw_name);
123 if (stat(userconfig,&finfo)<0 && stat(tmp,&finfo)==0)
124 symlink(tmp,userconfig);
126 /* trick: argc == 0, when message reply mode */
128 if (gethostname(localhost,FLEN-1)<0) strcpy(localhost,"localhost");
129 - snprintf(MAXS(tmp),"%s/msg@%s",userconfig,localhost);
130 + snprintf(tmp,sizeof(tmp)-1,"%s/msg@%s",userconfig,localhost);
131 if ((inf=rfopen(tmp,"r")) && fgetl(line,inf)) {
132 if ((cp=strchr(line,'\n'))) *cp=0;
133 if ((cp=strchr(line,'@'))) {
134 @@ -187,12 +187,12 @@ void destination(int argc, char **argv,
135 strcpy(recipient,larg);
137 /* check the sendfile alias file */
138 - snprintf(MAXS(aliasfile),"%s/aliases",userconfig);
139 + snprintf(aliasfile,sizeof(aliasfile)-1,"%s/aliases",userconfig);
140 if (check_alias(aliasfile,recipient,host,aopt)<0) {
142 #ifdef RESPECT_MAIL_ALIASES
143 /* check the elm alias file */
144 - snprintf(MAXS(aliasfile),"%s/.elm/aliases.text",pwe->pw_dir);
145 + snprintf(aliasfile,sizeof(aliasfile)-1,"%s/.elm/aliases.text",pwe->pw_dir);
146 if (check_alias(aliasfile,recipient,host,aopt)<0) {
149 @@ -342,7 +342,7 @@ int check_forward(int sockfd, char *recipient, char *host, char *redirect) {
152 if (!str_beq(reply,"200 ")) {
153 - snprintf(MAXS(tmp),"server error: %s",reply+4);
154 + snprintf(tmp,sizeof(tmp)-1,"server error: %s",reply+4);
156 if (client) message(prg,'F',tmp);
157 strcpy(redirect,reply+4);
158 @@ -405,7 +405,7 @@ int saft_connect(const char *type,
159 /* if the finger-port is specified get real port from there */
160 if (port==79 || !port) {
161 if ((cp=strchr(host,':'))) *cp=0;
162 - snprintf(MAXS(tmp),"opening connection to finger://%s/%s",host,recipient);
163 + snprintf(tmp,sizeof(tmp)-1,"opening connection to finger://%s/%s",host,recipient);
164 if (quiet<2) message(prg,'I',tmp);
165 port=finger_saft_port(recipient,host);
167 @@ -417,7 +417,7 @@ int saft_connect(const char *type,
170 /* initiate the SAFT-connection to the server */
171 - snprintf(MAXS(tmp),"opening connection to saft://%s/%s",host,recipient);
172 + snprintf(tmp,sizeof(tmp)-1,"opening connection to saft://%s/%s",host,recipient);
173 if (quiet<2) message(prg,'I',tmp);
174 sockfd=open_connection(host,port);
176 @@ -426,13 +426,13 @@ int saft_connect(const char *type,
177 /* host has no ip-address, but we can try more ... */
178 if (sockfd==-3 && str_eq(type,"file")) {
180 - snprintf(MAXS(tmp),"%s has no internet-address",host);
181 + snprintf(tmp,sizeof(tmp)-1,"%s has no internet-address",host);
182 if (quiet<2) message(prg,'W',tmp);
185 /* try generic saft-address for this host/domain */
187 - snprintf(MAXS(ahost),"saft.%s",host);
188 + snprintf(ahost,sizeof(ahost)-1,"saft.%s",host);
190 if(gethostbyname(ahost)){
192 @@ -446,7 +446,7 @@ int saft_connect(const char *type,
193 if (tolower(*answer)!='n' || !client) {
196 - snprintf(MAXS(tmp),"opening connection to %s@%s",recipient,host);
197 + snprintf(tmp,sizeof(tmp)-1,"opening connection to %s@%s",recipient,host);
198 if (quiet<2) message(prg,'I',tmp);
200 sockfd=open_connection(host,port);
201 @@ -458,13 +458,13 @@ int saft_connect(const char *type,
202 /* try user SAFT port on connection failure */
203 if (sockfd==-2 && str_eq(type,"file")) {
205 - snprintf(MAXS(tmp),"cannot connect to SAFT port %d on %s",
206 + snprintf(tmp,sizeof(tmp)-1,"cannot connect to SAFT port %d on %s",
208 message(prg,'E',tmp);
210 port=finger_saft_port(recipient,host);
211 if (port>0 && port!=SAFT) {
212 - snprintf(MAXS(tmp),"%s has no system SAFT server, "
213 + snprintf(tmp,sizeof(tmp)-1,"%s has no system SAFT server, "
214 "trying user SAFT server on port %d",host,port);
215 if (quiet<2) message(prg,'W',tmp);
216 sockfd=open_connection(host,port);
217 @@ -474,9 +474,9 @@ int saft_connect(const char *type,
221 - if (sockfd==-1) snprintf(MAXS(tmp),"cannot create a network socket");
222 - if (sockfd==-2) snprintf(MAXS(tmp),"cannot open connection to %s",host);
223 - if (sockfd==-3) snprintf(MAXS(tmp),"%s is unknown",host);
224 + if (sockfd==-1) snprintf(tmp,sizeof(tmp)-1,"cannot create a network socket");
225 + if (sockfd==-2) snprintf(tmp,sizeof(tmp)-1,"cannot open connection to %s",host);
226 + if (sockfd==-3) snprintf(tmp,sizeof(tmp)-1,"%s is unknown",host);
230 @@ -488,7 +488,7 @@ int saft_connect(const char *type,
231 /* no remote server or protocol error? */
232 sock_getline(sockfd,line);
233 if (!str_beq(line,"220 ") || !strstr(line,"SAFT")) {
234 - snprintf(MAXS(tmp),"No SAFT server on port %d at %s",port,host);
235 + snprintf(tmp,sizeof(tmp)-1,"No SAFT server on port %d at %s",port,host);
236 if ((cp=strrchr(tmp,':'))) *cp=0;
239 @@ -500,9 +500,9 @@ int saft_connect(const char *type,
242 /* send constant header lines */
243 - snprintf(MAXS(tmp),"FROM %s",user);
244 + snprintf(tmp,sizeof(tmp)-1,"FROM %s",user);
245 sendheader(sockfd,tmp);
246 - snprintf(MAXS(tmp),"TO %s",recipient);
247 + snprintf(tmp,sizeof(tmp)-1,"TO %s",recipient);
248 sock_putline(sockfd,tmp);
250 /* is there a forward set? */
251 @@ -659,7 +659,7 @@ int saft_connect(const char *type,
253 if ((cp=strchr(host,':'))) *cp=0;
255 - snprintf(MAXS(tmp),"opening connection to finger://%s/%s",host,recipient);
256 + snprintf(tmp,sizeof(tmp)-1,"opening connection to finger://%s/%s",host,recipient);
257 if (quiet<2) message(prg,'I',tmp);
258 service=finger_saft_port(recipient,host);
260 @@ -671,7 +671,7 @@ int saft_connect(const char *type,
263 /* initiate the SAFT-connection to the server */
264 - snprintf(MAXS(tmp),"opening connection to saft://%s/%s",host,recipient);
265 + snprintf(tmp,sizeof(tmp)-1,"opening connection to saft://%s/%s",host,recipient);
266 if (quiet<2) message(prg,'I',tmp);
267 sockfd=open_connection(host,service);
269 @@ -680,13 +680,13 @@ int saft_connect(const char *type,
270 /* host has no ip-address, but we can try more ... */
271 if (sockfd==-3 && str_eq(type,"file")) {
273 - snprintf(MAXS(tmp),"%s has no internet-address",host);
274 + snprintf(tmp,sizeof(tmp)-1,"%s has no internet-address",host);
275 if (quiet<2) message(prg,'W',tmp);
278 /* try generic saft-address for this host/domain */
279 if (strcasecmp(service, SERVICE) == 0 || strcmp(service, PORT_STRING) == 0) {
280 - snprintf(MAXS(ahost),"saft.%s",host);
281 + snprintf(ahost,sizeof(ahost)-1,"saft.%s",host);
283 sockfd=open_connection(host,service);
285 @@ -701,7 +701,7 @@ int saft_connect(const char *type,
286 if (tolower(*answer)!='n' || !client) {
289 - snprintf(MAXS(tmp),"opening connection to %s@%s",recipient,host);
290 + snprintf(tmp,sizeof(tmp)-1,"opening connection to %s@%s",recipient,host);
291 if (quiet<2) message(prg,'I',tmp);
294 @@ -715,14 +715,14 @@ int saft_connect(const char *type,
295 /* try user SAFT port on connection failure */
296 if (sockfd==-2 && str_eq(type,"file")) {
298 - snprintf(MAXS(tmp),"cannot connect to SAFT port %s on %s",
299 + snprintf(tmp,sizeof(tmp)-1,"cannot connect to SAFT port %s on %s",
301 message(prg,'E',tmp);
303 service=finger_saft_port(recipient,host);
304 if (service != NULL) needsFree = 1;
305 if (service != NULL && strcasecmp(service, SERVICE) != 0 && strcmp(service, PORT_STRING) != 0) {
306 - snprintf(MAXS(tmp),"%s has no system SAFT server, "
307 + snprintf(tmp,sizeof(tmp)-1,"%s has no system SAFT server, "
308 "trying user SAFT server on port %s",host,service);
309 if (quiet<2) message(prg,'W',tmp);
310 sockfd=open_connection(host,service);
311 @@ -733,10 +733,10 @@ int saft_connect(const char *type,
315 - if (sockfd==-1) snprintf(MAXS(tmp),"cannot create a network socket");
316 - if (sockfd==-2) snprintf(MAXS(tmp),"cannot open connection to %s",host);
317 - if (sockfd==-3) snprintf(MAXS(tmp),"%s is unknown",host);
318 - if (sockfd==-4) snprintf(MAXS(tmp),"out of memory");
319 + if (sockfd==-1) snprintf(tmp,sizeof(tmp)-1,"cannot create a network socket");
320 + if (sockfd==-2) snprintf(tmp,sizeof(tmp)-1,"cannot open connection to %s",host);
321 + if (sockfd==-3) snprintf(tmp,sizeof(tmp)-1,"%s is unknown",host);
322 + if (sockfd==-4) snprintf(tmp,sizeof(tmp)-1,"out of memory");
326 @@ -750,7 +750,7 @@ int saft_connect(const char *type,
327 /* no remote server or protocol error? */
328 sock_getline(sockfd,line);
329 if (!str_beq(line,"220 ") || !strstr(line,"SAFT")) {
330 - snprintf(MAXS(tmp),"No SAFT server on port %s at %s",service,host);
331 + snprintf(tmp,sizeof(tmp)-1,"No SAFT server on port %s at %s",service,host);
332 if ((cp=strrchr(tmp,':'))) *cp=0;
335 @@ -763,9 +763,9 @@ int saft_connect(const char *type,
338 /* send constant header lines */
339 - snprintf(MAXS(tmp),"FROM %s",user);
340 + snprintf(tmp,sizeof(tmp)-1,"FROM %s",user);
341 sendheader(sockfd,tmp);
342 - snprintf(MAXS(tmp),"TO %s",recipient);
343 + snprintf(tmp,sizeof(tmp)-1,"TO %s",recipient);
344 sock_putline(sockfd,tmp);
346 /* is there a forward set? */
347 diff --git a/src/fetchfile.c b/src/fetchfile.c
348 index bd9d3c7..cb12354 100644
349 --- a/src/fetchfile.c
350 +++ b/src/fetchfile.c
351 @@ -215,14 +215,14 @@ int main(int argc, char *argv[]) {
352 tmpdir=mktmpdir(verbose);
354 /* set various file names and check user spool and configuration directory */
355 - snprintf(MAXS(pgptmp),"%s/fetchfile.pgp",tmpdir);
356 - snprintf(MAXS(userspool),SPOOL"/%s",pwe->pw_name);
357 + snprintf(pgptmp,sizeof(pgptmp)-1,"%s/fetchfile.pgp",tmpdir);
358 + snprintf(userspool,sizeof(userspool)-1,SPOOL"/%s",pwe->pw_name);
359 if (stat(userspool,&finfo)<0) sendfiled_test(pwe->pw_name);
360 - snprintf(MAXS(userconfig),"%s/.sendfile",pwe->pw_dir);
361 - snprintf(MAXS(tmp),"%s/config",userspool);
362 + snprintf(userconfig,sizeof(userconfig)-1,"%s/.sendfile",pwe->pw_dir);
363 + snprintf(tmp,sizeof(tmp)-1,"%s/config",userspool);
364 if (stat(userconfig,&finfo)<0 && stat(userspool,&finfo)==0)
365 symlink(tmp,userconfig);
366 - snprintf(MAXS(tmp),"%s/.sfspool",pwe->pw_dir);
367 + snprintf(tmp,sizeof(tmp)-1,"%s/.sfspool",pwe->pw_dir);
368 if (stat(tmp,&finfo)==0 && finfo.st_mode&S_IFDIR) strcpy(userspool,tmp);
370 /* scan the command line on options */
371 @@ -303,7 +303,7 @@ int main(int argc, char *argv[]) {
372 /* check tmp files */
374 if (stat(pgptmp,&finfo)==0) {
375 - snprintf(MAXS(tmp),
376 + snprintf(tmp,sizeof(tmp)-1,
377 "tmp-file %s does already exist and cannot be deleted",pgptmp);
378 message(prg,'F',tmp);
380 @@ -332,19 +332,19 @@ int main(int argc, char *argv[]) {
383 /* check pgp key files */
384 - snprintf(MAXS(tmp),"%s/private.pgp",userconfig);
385 + snprintf(tmp,sizeof(tmp)-1,"%s/private.pgp",userconfig);
386 if (stat(tmp,&finfo)<0) {
387 - snprintf(MAXS(line),"no access to %s (try 'fetchfile -I' first)",tmp);
388 + snprintf(line,sizeof(line)-1,"no access to %s (try 'fetchfile -I' first)",tmp);
389 message(prg,'F',line);
391 - snprintf(MAXS(tmp),"%s/public.pgp",userconfig);
392 + snprintf(tmp,sizeof(tmp)-1,"%s/public.pgp",userconfig);
393 if (stat(tmp,&finfo)<0) {
394 - snprintf(MAXS(line),"no access to %s (try 'fetchfile -I' first)",tmp);
395 + snprintf(line,sizeof(line)-1,"no access to %s (try 'fetchfile -I' first)",tmp);
396 message(prg,'F',line);
399 /* parse the user config-file */
400 - snprintf(MAXS(tmp),"%s/config",userconfig);
401 + snprintf(tmp,sizeof(tmp)-1,"%s/config",userconfig);
402 if ((inf=rfopen(tmp,"r"))) {
403 while (fgetl(line,inf)) {
405 @@ -386,24 +386,24 @@ int main(int argc, char *argv[]) {
407 if (!*id) strcpy(id,pwe->pw_name);
408 if (!*server) strcpy(server,"localhost");
409 - snprintf(MAXS(listfile),"%s/%s@%s:fetch.lis",userspool,id,server);
410 + snprintf(listfile,sizeof(listfile)-1,"%s/%s@%s:fetch.lis",userspool,id,server);
412 /* initiate the connection to the server */
415 message(prg,'F',"no SAFT server is defined");
417 - snprintf(MAXS(tmp),"connecting to SAFT server %s",server);
418 + snprintf(tmp,sizeof(tmp)-1,"connecting to SAFT server %s",server);
419 if (quiet<2) message(prg,'I',tmp);
420 #ifndef ENABLE_MULTIPROTOCOL
421 sockfd=open_connection(server,SAFT);
423 sockfd=open_connection(server,SERVICE);
425 - if (sockfd==-1) snprintf(MAXS(tmp),"cannot create a network socket");
426 - if (sockfd==-2) snprintf(MAXS(tmp),"cannot open connection to %s",server);
427 - if (sockfd==-3) snprintf(MAXS(tmp),"%s is unknown",server);
428 - if (sockfd==-4) snprintf(MAXS(tmp),"out of memory");
429 + if (sockfd==-1) snprintf(tmp,sizeof(tmp)-1,"cannot create a network socket");
430 + if (sockfd==-2) snprintf(tmp,sizeof(tmp)-1,"cannot open connection to %s",server);
431 + if (sockfd==-3) snprintf(tmp,sizeof(tmp)-1,"%s is unknown",server);
432 + if (sockfd==-4) snprintf(tmp,sizeof(tmp)-1,"out of memory");
435 message(prg,'F',tmp);
436 @@ -413,22 +413,22 @@ int main(int argc, char *argv[]) {
437 sock_getline(sockfd,line);
438 if (!str_beq(line,"220 ") || !strstr(line,"SAFT")) {
440 - snprintf(MAXS(tmp),"No SAFT server on port %d at %s",SAFT,server);
441 + snprintf(tmp,sizeof(tmp)-1,"No SAFT server on port %d at %s",SAFT,server);
442 message(prg,'F',tmp);
446 - snprintf(MAXS(tmp),"ID %s",id);
447 + snprintf(tmp,sizeof(tmp)-1,"ID %s",id);
448 sock_putline(sockfd,tmp);
449 sock_getline(sockfd,line);
450 if (str_beq(line,"520")) {
452 - snprintf(MAXS(tmp),"user %s is unknown on SAFT-server %s",id,server);
453 + snprintf(tmp,sizeof(tmp)-1,"user %s is unknown on SAFT-server %s",id,server);
454 message(prg,'F',tmp);
456 if (!str_beq(line,"331")) {
458 - snprintf(MAXS(tmp),"server error: %s",line+4);
459 + snprintf(tmp,sizeof(tmp)-1,"server error: %s",line+4);
460 message(prg,'F',tmp);
463 @@ -440,7 +440,7 @@ int main(int argc, char *argv[]) {
464 outf=rfopen(pgptmp,"w");
467 - snprintf(MAXS(tmp),"cannot open/write to %s",pgptmp);
468 + snprintf(tmp,sizeof(tmp)-1,"cannot open/write to %s",pgptmp);
469 message(prg,'F',tmp);
471 fprintf(outf,"%s",cp+1);
472 @@ -448,13 +448,13 @@ int main(int argc, char *argv[]) {
474 /* goto user spool directory */
475 if (chdir(userspool)<0) {
476 - snprintf(MAXS(tmp),"cannot change to %s",userspool);
477 + snprintf(tmp,sizeof(tmp)-1,"cannot change to %s",userspool);
478 message(prg,'F',tmp);
482 /* DONT REMOVE 2>/dev/null IN THE FOLLOWING LINE! */
483 - snprintf(MAXS(cmd),"cd %s; PGPPATH='.' %s -sbaf "
484 + snprintf(cmd,sizeof(cmd)-1,"cd %s; PGPPATH='.' %s -sbaf "
485 "+secring=private.pgp +pubring=public.pgp <%s 2>/dev/null",
486 userconfig,pgp_bin,pgptmp);
487 if (verbose) printf("call: %s\n",cmd);
488 @@ -478,7 +478,7 @@ int main(int argc, char *argv[]) {
491 iso2utf(tmp,response);
492 - snprintf(MAXS(response),"AUTH %s",tmp);
493 + snprintf(response,sizeof(response)-1,"AUTH %s",tmp);
494 sendheader(sockfd,response);
496 /* config file transfer? */
497 @@ -492,7 +492,7 @@ int main(int argc, char *argv[]) {
499 strcpy(conffile,tmp);
501 - snprintf(MAXS(conffile),"%s/%s",swd,tmp);
502 + snprintf(conffile,sizeof(conffile)-1,"%s/%s",swd,tmp);
504 /* write config file */
506 @@ -501,23 +501,23 @@ int main(int argc, char *argv[]) {
510 - snprintf(MAXS(tmp),"CONF WRITE %s",cp);
511 + snprintf(tmp,sizeof(tmp)-1,"CONF WRITE %s",cp);
512 sock_putline(sockfd,tmp);
513 sock_getline(sockfd,line);
514 if (!str_beq(line,"302 ") && !str_beq(line,"200 ")) {
516 - snprintf(MAXS(tmp),"server error: %s",line+4);
517 + snprintf(tmp,sizeof(tmp)-1,"server error: %s",line+4);
518 message(prg,'F',tmp);
521 inf=rfopen(conffile,"r");
523 - snprintf(MAXS(tmp),"cannot open %s",conffile);
524 + snprintf(tmp,sizeof(tmp)-1,"cannot open %s",conffile);
525 message(prg,'F',tmp);
529 - snprintf(MAXS(tmp),"transfering %s",conffile);
530 + snprintf(tmp,sizeof(tmp)-1,"transfering %s",conffile);
531 message(prg,'I',tmp);
534 @@ -532,7 +532,7 @@ int main(int argc, char *argv[]) {
535 sock_getline(sockfd,line);
536 if (!str_beq(line,"201 ")) {
538 - snprintf(MAXS(tmp),"server error: %s",line+4);
539 + snprintf(tmp,sizeof(tmp)-1,"server error: %s",line+4);
540 message(prg,'F',tmp);
543 @@ -542,12 +542,12 @@ int main(int argc, char *argv[]) {
547 - snprintf(MAXS(tmp),"CONF READ %s",cp);
548 + snprintf(tmp,sizeof(tmp)-1,"CONF READ %s",cp);
549 sock_putline(sockfd,tmp);
550 while (sock_getline(sockfd,line)) {
551 if (!str_beq(line,"250")) {
553 - snprintf(MAXS(tmp),"server error: %s",line+4);
554 + snprintf(tmp,sizeof(tmp)-1,"server error: %s",line+4);
555 message(prg,'F',tmp);
557 if (str_beq("250 ",line)) break;
558 @@ -592,11 +592,11 @@ int main(int argc, char *argv[]) {
559 number=atoi(argv[i]);
561 if (delete_file(sockfd,number)<0) {
562 - snprintf(MAXS(tmp),"cannot delete file #%d from server",number);
563 + snprintf(tmp,sizeof(tmp)-1,"cannot delete file #%d from server",number);
565 message(prg,'E',prg);
567 - snprintf(MAXS(tmp),"file #%d deleted from server",number);
568 + snprintf(tmp,sizeof(tmp)-1,"file #%d deleted from server",number);
569 if (quiet<2) message(prg,'I',tmp);
572 @@ -616,7 +616,7 @@ int main(int argc, char *argv[]) {
573 get_list(sockfd,server,id,listf);
576 - snprintf(MAXS(tmp),"cannot open %s for writing",listfile);
577 + snprintf(tmp,sizeof(tmp)-1,"cannot open %s for writing",listfile);
578 message(prg,'F',tmp);
581 @@ -624,7 +624,7 @@ int main(int argc, char *argv[]) {
583 listf=rfopen(listfile,"r");
585 - snprintf(MAXS(tmp),"cannot open %s for reading",listfile);
586 + snprintf(tmp,sizeof(tmp)-1,"cannot open %s for reading",listfile);
587 message(prg,'F',tmp);
589 while (fgetl(line,listf)) {
590 @@ -642,11 +642,11 @@ int main(int argc, char *argv[]) {
593 if (delete_file(sockfd,number)<0) {
594 - snprintf(MAXS(tmp),"cannot delete file #%d (%s) from server",number,fname);
595 + snprintf(tmp,sizeof(tmp)-1,"cannot delete file #%d (%s) from server",number,fname);
597 message(prg,'E',prg);
599 - snprintf(MAXS(tmp),"file #%d (%s) deleted from server",number,fname);
600 + snprintf(tmp,sizeof(tmp)-1,"file #%d (%s) deleted from server",number,fname);
601 if (quiet<2) message(prg,'I',tmp);
604 @@ -666,7 +666,7 @@ int main(int argc, char *argv[]) {
605 for (i=optind;i<argc;i++) {
606 listf=rfopen(listfile,"r");
608 - snprintf(MAXS(tmp),"cannot open %s for reading",listfile);
609 + snprintf(tmp,sizeof(tmp)-1,"cannot open %s for reading",listfile);
610 message(prg,'F',tmp);
612 while (fgetl(line,listf)) {
613 @@ -683,11 +683,11 @@ int main(int argc, char *argv[]) {
616 if (delete_file(sockfd,number)<0) {
617 - snprintf(MAXS(tmp),"cannot delete file #%d (%s) from server",number,fname);
618 + snprintf(tmp,sizeof(tmp)-1,"cannot delete file #%d (%s) from server",number,fname);
620 message(prg,'E',prg);
622 - snprintf(MAXS(tmp),"file #%d (%s) deleted from server",number,fname);
623 + snprintf(tmp,sizeof(tmp)-1,"file #%d (%s) deleted from server",number,fname);
624 if (quiet<2) message(prg,'I',tmp);
627 @@ -751,7 +751,7 @@ void rexit(int n) {
629 /* change back to starting directory */
631 - snprintf(MAXS(tmp),"cannot change back to %s",swd);
632 + snprintf(tmp,sizeof(tmp)-1,"cannot change back to %s",swd);
633 message(prg,'E',tmp);
635 if (verbose) printf("shell-call: %s\n",rfilen);
636 @@ -776,7 +776,7 @@ int delete_file(int sockfd, int number) {
637 char line[MAXLEN]; /* one line of text */
639 /* send LIST command */
640 - snprintf(MAXS(line),"DEL %d",number);
641 + snprintf(line,sizeof(line)-1,"DEL %d",number);
642 sock_putline(sockfd,line);
644 sock_getline(sockfd,line);
645 @@ -827,7 +827,7 @@ int get_list(int sockfd, const char *server, const char *id, FILE *listf) {
646 /* invalid answer? */
647 if (!str_beq(line,"250")) {
649 - snprintf(MAXS(tmp),"invalid answer from server: %s",line+4);
650 + snprintf(tmp,sizeof(tmp)-1,"invalid answer from server: %s",line+4);
651 message(prg,'E',tmp);
654 @@ -956,14 +956,14 @@ int get_file(int sockfd, int number, int ptso) {
655 if (!id) message(prg,'F',"cannot create local spool file");
657 /* open spool header and data files */
658 - snprintf(MAXS(shfile),"%d.h",id);
659 - snprintf(MAXS(sdfile),"%d.d",id);
660 + snprintf(shfile,sizeof(shfile)-1,"%d.h",id);
661 + snprintf(sdfile,sizeof(sdfile)-1,"%d.d",id);
662 sdfd=open(sdfile,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR);
663 shfd=open(shfile,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR);
664 if (shfd<0 || sdfd<0) message(prg,'F',"cannot create local spool file");
667 - snprintf(MAXS(tmp),"GET HEADER %d",number);
668 + snprintf(tmp,sizeof(tmp)-1,"GET HEADER %d",number);
669 sock_putline(sockfd,tmp);
672 @@ -981,7 +981,7 @@ int get_file(int sockfd, int number, int ptso) {
676 - snprintf(MAXS(tmp),"server-error: %s",line+4);
677 + snprintf(tmp,sizeof(tmp)-1,"server-error: %s",line+4);
678 message(prg,'E',tmp);
681 @@ -1003,7 +1003,7 @@ int get_file(int sockfd, int number, int ptso) {
682 if (str_beq(line+4,"FROM")) {
683 if ((cp=strchr(line+10,' '))) {
685 - snprintf(MAXS(tmp),"%s (%s)",line+9,cp+1);
686 + snprintf(tmp,sizeof(tmp)-1,"%s (%s)",line+9,cp+1);
690 @@ -1050,15 +1050,15 @@ int get_file(int sockfd, int number, int ptso) {
693 if (flp && flp->csize==offset) {
694 - snprintf(MAXS(tmp),"file %d (%s) has been already fetched",number,fname);
695 + snprintf(tmp,sizeof(tmp)-1,"file %d (%s) has been already fetched",number,fname);
696 message(prg,'I',tmp);
700 - snprintf(MAXS(tmp),"resuming fetching file %d (%s) with %ld kB",
701 + snprintf(tmp,sizeof(tmp)-1,"resuming fetching file %d (%s) with %ld kB",
702 number,fname,(size+1023)/1024);
704 - snprintf(MAXS(tmp),"fetching file %d (%s) with %ld kB",
705 + snprintf(tmp,sizeof(tmp)-1,"fetching file %d (%s) with %ld kB",
706 number,fname,(size+1023)/1024);
707 message(prg,'I',tmp);
709 @@ -1072,7 +1072,7 @@ int get_file(int sockfd, int number, int ptso) {
713 - snprintf(MAXS(tmp),"GET FILE %d %ld",number,offset);
714 + snprintf(tmp,sizeof(tmp)-1,"GET FILE %d %ld",number,offset);
715 sock_putline(sockfd,tmp);
716 sock_getline(sockfd,line);
718 @@ -1084,7 +1084,7 @@ int get_file(int sockfd, int number, int ptso) {
722 - snprintf(MAXS(tmp),"server-error: %s",line+4);
723 + snprintf(tmp,sizeof(tmp)-1,"server-error: %s",line+4);
724 message(prg,'E',tmp);
727 @@ -1096,7 +1096,7 @@ int get_file(int sockfd, int number, int ptso) {
730 if (offset && quiet<2) {
731 - snprintf(MAXS(tmp),"resuming at byte %ld",offset);
732 + snprintf(tmp,sizeof(tmp)-1,"resuming at byte %ld",offset);
736 @@ -1154,10 +1154,10 @@ int get_file(int sockfd, int number, int ptso) {
740 - snprintf(MAXS(tmp),
741 + snprintf(tmp,sizeof(tmp)-1,
742 "transfer of %s completed: %.1f kB/s",fname,thruput/1024);
744 - snprintf(MAXS(tmp),
745 + snprintf(tmp,sizeof(tmp)-1,
746 "transfer of %s completed: %d byte/s",fname,(int)thruput);
749 @@ -1204,10 +1204,10 @@ void init() {
750 printf("\nThis is the init routine for %s.\n",prg);
751 printf("It will create the necessary pgp files and the spool directory.\n");
752 printf("You can press Ctrl-C at any time to stop this procedure.\n\n");
753 - snprintf(MAXS(userspool),SPOOL"/%s",pwe->pw_name);
754 + snprintf(userspool,sizeof(userspool)-1,SPOOL"/%s",pwe->pw_name);
755 if (stat(userspool,&finfo)<0 || !(finfo.st_mode&S_IFDIR)) {
756 printf("User spool %s does not exist.\n",userspool);
757 - snprintf(MAXS(userspool),"%s/.sfspool",pwe->pw_dir);
758 + snprintf(userspool,sizeof(userspool)-1,"%s/.sfspool",pwe->pw_dir);
759 printf("May I create local spool %s? ",userspool);
761 if (*answer!='y' && *answer!='Y') {
762 @@ -1233,7 +1233,7 @@ void init() {
765 if (!(outf=rfopen(configf,"a"))) {
766 - snprintf(MAXS(tmp),"cannot open %s",configf);
767 + snprintf(tmp,sizeof(tmp)-1,"cannot open %s",configf);
768 message(prg,'F',tmp);
770 printf("What is the address of your SAFT server where you want to "
771 @@ -1299,11 +1299,11 @@ int sendfiled_test(const char *user) {
772 if (!str_beq(line,"220 ") || !strstr(line,"SAFT")) return(-1);
774 /* test if you can receive messages */
775 - snprintf(MAXS(line),"FROM %s",user);
776 + snprintf(line,sizeof(line)-1,"FROM %s",user);
777 sock_putline(sockfd,line);
778 sock_getline(sockfd,line);
779 if (!str_beq(line,"200 ")) return(-1);
780 - snprintf(MAXS(line),"TO %s",user);
781 + snprintf(line,sizeof(line)-1,"TO %s",user);
782 sock_putline(sockfd,line);
783 sock_getline(sockfd,line);
784 if (!str_beq(line,"200 ")) return(-1);
785 diff --git a/src/io.c b/src/io.c
786 index 7e5814c..e011165 100644
789 @@ -132,7 +132,7 @@ int fcopy(const char *from, const char *to, mode_t mode) {
791 /* get the original file size */
792 if (stat(from,&finfo)<0) {
793 - snprintf(MAXS(tmp),"cannot access '%s'",from);
794 + snprintf(tmp,sizeof(tmp)-1,"cannot access '%s'",from);
798 @@ -147,7 +147,7 @@ int fcopy(const char *from, const char *to, mode_t mode) {
799 /* open source file */
800 fdin=open(from,O_RDONLY|O_LARGEFILE,0);
802 - snprintf(MAXS(tmp),"error opening '%s'",from);
803 + snprintf(tmp,sizeof(tmp)-1,"error opening '%s'",from);
807 @@ -158,7 +158,7 @@ int fcopy(const char *from, const char *to, mode_t mode) {
808 /* open destination file */
809 fdout=creat(to,mode);
811 - snprintf(MAXS(tmp),"error creating '%s'",to);
812 + snprintf(tmp,sizeof(tmp)-1,"error creating '%s'",to);
816 @@ -180,7 +180,7 @@ int fcopy(const char *from, const char *to, mode_t mode) {
820 - snprintf(MAXS(tmp),"error writing '%s'",to);
821 + snprintf(tmp,sizeof(tmp)-1,"error writing '%s'",to);
825 @@ -212,7 +212,7 @@ int fcopy(const char *from, const char *to, mode_t mode) {
829 - snprintf(MAXS(tmp),"error reading '%s'",from);
830 + snprintf(tmp,sizeof(tmp)-1,"error reading '%s'",from);
834 @@ -220,7 +220,7 @@ int fcopy(const char *from, const char *to, mode_t mode) {
835 /* count mismatch or read/write errors? */
838 - snprintf(MAXS(tmp),"wrong byte count for '%s'",from);
839 + snprintf(tmp,sizeof(tmp)-1,"wrong byte count for '%s'",from);
843 @@ -334,12 +334,12 @@ char *mktmpdir(int verbose) {
846 if (mkdir(tmpdir,S_IRWXU)<0 || chmod(tmpdir,S_IRWXU)<0) {
847 - snprintf(MAXS(tmp),"cannot create tmpdir %s",tmpdir);
848 + snprintf(tmp,sizeof(tmp)-1,"cannot create tmpdir %s",tmpdir);
853 - snprintf(MAXS(tmp),"directory for temporary files is: %s",tmpdir);
854 + snprintf(tmp,sizeof(tmp)-1,"directory for temporary files is: %s",tmpdir);
858 @@ -365,7 +365,7 @@ void rmtmpdir(char *tmpdir) {
860 if (chdir(tmpdir) < 0 || !(dp=opendir(tmpdir))) {
862 - snprintf(MAXS(tmp),"cleanup: cannot open %s",tmpdir);
863 + snprintf(tmp,sizeof(tmp)-1,"cleanup: cannot open %s",tmpdir);
867 @@ -378,7 +378,7 @@ void rmtmpdir(char *tmpdir) {
870 if (unlink(dire->d_name) < 0) {
871 - snprintf(MAXS(tmp),"cannot remove %s/%s",tmpdir,dire->d_name);
872 + snprintf(tmp,sizeof(tmp)-1,"cannot remove %s/%s",tmpdir,dire->d_name);
876 @@ -386,7 +386,7 @@ void rmtmpdir(char *tmpdir) {
879 if (rmdir(tmpdir) < 0) {
880 - snprintf(MAXS(tmp),"cannot remove %s",tmpdir);
881 + snprintf(tmp,sizeof(tmp)-1,"cannot remove %s",tmpdir);
885 @@ -483,7 +483,7 @@ int vsystem(const char *cmd) {
889 - snprintf(MAXS(tmp),"shell-call: %s\n",cmd);
890 + snprintf(tmp,sizeof(tmp)-1,"shell-call: %s\n",cmd);
891 message(prg,'I',tmp);
894 @@ -506,8 +506,8 @@ FILE* vpopen(const char *cmd, const char *type) {
898 - case 'r': snprintf(MAXS(tmp),"shell-call: %s|",cmd); break;
899 - case 'w': snprintf(MAXS(tmp),"shell-call: |%s",cmd); break;
900 + case 'r': snprintf(tmp,sizeof(tmp)-1,"shell-call: %s|",cmd); break;
901 + case 'w': snprintf(tmp,sizeof(tmp)-1,"shell-call: |%s",cmd); break;
903 message(prg,'I',tmp);
905 diff --git a/src/net.c b/src/net.c
906 index eed63ac..64fcbcf 100644
909 @@ -458,7 +458,7 @@ int sock_getline(int fd, char *line) {
910 if (n+1==MAXLEN && line[n] != '\n') {
913 - snprintf(MAXS(tmp),"network socket data overrun (read bytes: %d)",n);
914 + snprintf(tmp,sizeof(tmp)-1,"network socket data overrun (read bytes: %d)",n);
916 message("",'F',line);
918 @@ -530,7 +530,7 @@ char *getreply(int fd) {
921 strcpy(msg,"server has closed the connection");
922 - if (*reply) snprintf(MAXS(msg),"%s, last data: \"%s\"",msg,reply);
923 + if (*reply) snprintf(msg,sizeof(msg)-1,"%s, last data: \"%s\"",msg,reply);
927 @@ -542,7 +542,7 @@ char *getreply(int fd) {
928 /* reply message too short? */
931 - snprintf(MAXS(msg),"corrupt reply: \"%s\"",reply);
932 + snprintf(msg,sizeof(msg)-1,"corrupt reply: \"%s\"",reply);
936 @@ -565,7 +565,7 @@ char *getreply(int fd) {
937 /* fatal server error? */
940 - snprintf(MAXS(msg),"server error: %s",&reply[4]);
941 + snprintf(msg,sizeof(msg)-1,"server error: %s",&reply[4]);
945 @@ -640,7 +640,7 @@ int sendheader(int fd, char *line) {
946 if (str_beq(reply,"202")) return(1);
949 - snprintf(MAXS(msg),"server error: %s",&reply[4]);
950 + snprintf(msg,sizeof(msg)-1,"server error: %s",&reply[4]);
951 message(prg,'F',msg);
954 @@ -725,7 +725,7 @@ int send_data(int sockfd, off_t size, const char *file,
955 if (!str_beq(reply,"230 ")) {
958 - snprintf(MAXS(tmp),"server error: %s",&reply[4]);
959 + snprintf(tmp,sizeof(tmp)-1,"server error: %s",&reply[4]);
963 @@ -742,7 +742,7 @@ int send_data(int sockfd, off_t size, const char *file,
965 /* file already transmitted? */
966 if (str_beq(reply,"531 ")) {
967 - snprintf(MAXS(tmp),
968 + snprintf(tmp,sizeof(tmp)-1,
969 "file %s has been already transmitted - ignored.",iso_name);
970 if (quiet<2) message("",'W',tmp);
972 @@ -751,7 +751,7 @@ int send_data(int sockfd, off_t size, const char *file,
973 /* server reply ok? */
974 if (!str_beq(reply,"302 ")) {
976 - snprintf(MAXS(tmp),"corrupt server reply: %s",&reply[4]);
977 + snprintf(tmp,sizeof(tmp)-1,"corrupt server reply: %s",&reply[4]);
981 @@ -764,7 +764,7 @@ int send_data(int sockfd, off_t size, const char *file,
982 ffd=open(file,O_RDONLY,0);
983 if (ffd<0 || lseek(ffd,offset,SEEK_SET)<0) {
985 - snprintf(MAXS(tmp),"error reading %s",iso_name);
986 + snprintf(tmp,sizeof(tmp)-1,"error reading %s",iso_name);
990 @@ -775,12 +775,12 @@ int send_data(int sockfd, off_t size, const char *file,
994 - snprintf(MAXS(tmp),"resuming %s at byte %lld",iso_name,offset);
995 + snprintf(tmp,sizeof(tmp)-1,"resuming %s at byte %lld",iso_name,offset);
996 if (quiet<2) message("",'I',tmp);
1000 - snprintf(MAXS(tmp),"begin transfer of %s with %lld bytes",fname,size);
1001 + snprintf(tmp,sizeof(tmp)-1,"begin transfer of %s with %lld bytes",fname,size);
1002 message("",'I',tmp);
1005 @@ -805,7 +805,7 @@ int send_data(int sockfd, off_t size, const char *file,
1006 if (readn(ffd,packet,packet_size)<packet_size) {
1008 if (!quiet) printf("\n");
1009 - snprintf(MAXS(tmp),"error reading %s",iso_name);
1010 + snprintf(tmp,sizeof(tmp)-1,"error reading %s",iso_name);
1011 message("",'E',tmp);
1014 @@ -844,7 +844,7 @@ int send_data(int sockfd, off_t size, const char *file,
1015 if ((n=size-nblocks*packet_size) > 0) {
1016 if (readn(ffd,packet,n)<n) {
1018 - snprintf(MAXS(tmp),"error reading %s",iso_name);
1019 + snprintf(tmp,sizeof(tmp)-1,"error reading %s",iso_name);
1020 message("",'E',tmp);
1023 @@ -882,10 +882,10 @@ int send_data(int sockfd, off_t size, const char *file,
1027 - snprintf(MAXS(tmp),
1028 + snprintf(tmp,sizeof(tmp)-1,
1029 "transfer of %s completed: %.1f kB/s",fname,thruput/1024);
1031 - snprintf(MAXS(tmp),
1032 + snprintf(tmp,sizeof(tmp)-1,
1033 "transfer of %s completed: %d byte/s",fname,(int)thruput);
1034 message("",'I',tmp);
1036 @@ -909,7 +909,7 @@ int send_data(int sockfd, off_t size, const char *file,
1038 if (sockfd && !str_beq(getreply(sockfd),"201 ")) {
1040 - snprintf(MAXS(tmp),"transfer failed for %s",iso_name);
1041 + snprintf(tmp,sizeof(tmp)-1,"transfer failed for %s",iso_name);
1043 message("",'E',tmp);
1045 diff --git a/src/receive.c b/src/receive.c
1046 index 50ae63e..96501b1 100644
1049 @@ -287,11 +287,11 @@ int main(int argc, char *argv[]) {
1050 case 'q': quiet=1; break;
1051 case 'p': preserve=1; break;
1052 case 'H': header=1; break;
1053 - case 'S': snprintf(MAXS(pgpring),"%s",optarg); break;
1054 + case 'S': snprintf(pgpring,sizeof(pgpring)-1,"%s",optarg); break;
1055 case 'v': opt_v="-v"; verbose=1; break;
1056 - case 'f': snprintf(MAXS(from),"%s",optarg); break;
1057 - case 'b': snprintf(MAXS(bounce),"%s",optarg); break;
1058 - case 'Z': snprintf(MAXS(userspool),"%s",optarg); break;
1059 + case 'f': snprintf(from,sizeof(from)-1,"%s",optarg); break;
1060 + case 'b': snprintf(bounce,sizeof(bounce)-1,"%s",optarg); break;
1061 + case 'Z': snprintf(userspool,sizeof(userspool)-1,"%s",optarg); break;
1062 case 'V': message(prg,'I',"version "VERSION" revision "REVISION"");
1065 @@ -318,18 +318,18 @@ int main(int argc, char *argv[]) {
1066 /* determine the spool directory */
1068 if ((cp=getenv("SF_SPOOL"))) {
1069 - snprintf(MAXS(userspool),"%s",cp);
1070 + snprintf(userspool,sizeof(userspool)-1,"%s",cp);
1072 - snprintf(MAXS(userspool),"%s/.sfspool",pwe->pw_dir);
1073 + snprintf(userspool,sizeof(userspool)-1,"%s/.sfspool",pwe->pw_dir);
1074 if (stat(userspool,&finfo)<0 || !(finfo.st_mode&S_IFDIR))
1075 - snprintf(MAXS(userspool),SPOOL"/%s",pwe->pw_name);
1076 + snprintf(userspool,sizeof(userspool)-1,SPOOL"/%s",pwe->pw_name);
1079 - if (*userspool=='Z') snprintf(MAXS(userspool),SPOOL"/%s",pwe->pw_name);
1080 + if (*userspool=='Z') snprintf(userspool,sizeof(userspool)-1,SPOOL"/%s",pwe->pw_name);
1082 /* does the spool directory exist? */
1083 if (stat(userspool,&finfo)<0 || (finfo.st_mode&S_IFMT)!=S_IFDIR) {
1084 - snprintf(MAXS(tmp),"spool directory %s does not exist",userspool);
1085 + snprintf(tmp,sizeof(tmp)-1,"spool directory %s does not exist",userspool);
1087 message(prg,'E',tmp);
1089 @@ -337,7 +337,7 @@ int main(int argc, char *argv[]) {
1091 /* correct permissions for the spool directory? */
1092 if (!(finfo.st_mode&S_IRWXU) || finfo.st_uid!=getuid()) {
1093 - snprintf(MAXS(tmp),
1094 + snprintf(tmp,sizeof(tmp)-1,
1095 "no access to spool directory %s (wrong permissions)",
1098 @@ -348,7 +348,7 @@ int main(int argc, char *argv[]) {
1099 /* are there any files to receive? */
1100 sls=scanspool(from);
1102 - snprintf(MAXS(tmp),"no files found in spool directory %s",userspool);
1103 + snprintf(tmp,sizeof(tmp)-1,"no files found in spool directory %s",userspool);
1104 message(prg,'W',tmp);
1107 @@ -359,7 +359,7 @@ int main(int argc, char *argv[]) {
1110 /* set log file read status (st_atime) for xhoppel */
1111 - snprintf(MAXS(tmp),"%s/log",userspool);
1112 + snprintf(tmp,sizeof(tmp)-1,"%s/log",userspool);
1113 inf=rfopen(tmp,"r");
1116 @@ -420,15 +420,15 @@ int main(int argc, char *argv[]) {
1118 /* set tmp file names */
1119 tmpdir=mktmpdir(strlen(opt_v));
1120 - snprintf(MAXS(tartmp),"%s/receive.tar",tmpdir);
1121 - snprintf(MAXS(fileslist),"%s/files",tmpdir);
1122 - snprintf(MAXS(error_log),"%s/error.log",tmpdir);
1123 + snprintf(tartmp,sizeof(tartmp)-1,"%s/receive.tar",tmpdir);
1124 + snprintf(fileslist,sizeof(fileslist)-1,"%s/files",tmpdir);
1125 + snprintf(error_log,sizeof(error_log)-1,"%s/error.log",tmpdir);
1130 if (list(sls,listformat,from,pgpring,number,argc,argv)<0) {
1131 - snprintf(MAXS(tmp),"no files in spool directory %s",userspool);
1132 + snprintf(tmp,sizeof(tmp)-1,"no files in spool directory %s",userspool);
1133 message(prg,'W',tmp);
1136 @@ -456,10 +456,10 @@ int main(int argc, char *argv[]) {
1140 - snprintf(MAXS(tmp),"%s %d",bouncelist,id);
1141 + snprintf(tmp,sizeof(tmp)-1,"%s %d",bouncelist,id);
1142 strcpy(bouncelist,tmp);
1144 - snprintf(MAXS(bouncelist),"%d",id);
1145 + snprintf(bouncelist,sizeof(bouncelist)-1,"%d",id);
1148 receive_sf(flp,pgpring,header);
1149 @@ -473,7 +473,7 @@ int main(int argc, char *argv[]) {
1153 - snprintf(MAXS(tmp),"spool file #%d not found",id);
1154 + snprintf(tmp,sizeof(tmp)-1,"spool file #%d not found",id);
1155 message(prg,'W',tmp);
1158 @@ -509,10 +509,10 @@ int main(int argc, char *argv[]) {
1162 - snprintf(MAXS(tmp),"%s %d",bouncelist,flp->id);
1163 + snprintf(tmp,sizeof(tmp)-1,"%s %d",bouncelist,flp->id);
1164 strcpy(bouncelist,tmp);
1166 - snprintf(MAXS(bouncelist),"%d",flp->id);
1167 + snprintf(bouncelist,sizeof(bouncelist)-1,"%d",flp->id);
1169 receive_sf(flp,pgpring,header);
1171 @@ -524,7 +524,7 @@ int main(int argc, char *argv[]) {
1174 if (!found && !all) {
1175 - snprintf(MAXS(tmp),"file %s not found",pattern);
1176 + snprintf(tmp,sizeof(tmp)-1,"file %s not found",pattern);
1177 message(prg,'W',tmp);
1180 @@ -537,10 +537,10 @@ int main(int argc, char *argv[]) {
1181 /* files to bounce? */
1182 if (*bounce && *bouncelist) {
1184 - snprintf(MAXS(tmp),
1185 + snprintf(tmp,sizeof(tmp)-1,
1186 "sendfile -bk=y %s %s %s",opt_v,bouncelist,bounce);
1188 - snprintf(MAXS(tmp),
1189 + snprintf(tmp,sizeof(tmp)-1,
1190 "sendfile -bk=n %s %s %s",opt_v,bouncelist,bounce);
1193 @@ -668,17 +668,17 @@ int list(struct senderlist *sls, int format, char *from, char *pgpring,
1195 /* encrypted, compressed or normal tar file? */
1196 if (flp->flags&F_CRYPT)
1197 - snprintf(MAXS(showtar),"%s %s -f < %s/%d.d | %s tvf -",
1198 + snprintf(showtar,sizeof(showtar)-1,"%s %s -f < %s/%d.d | %s tvf -",
1199 pgp_bin,pgpvm,userspool,flp->id,tar_bin);
1200 else if (flp->flags&F_COMPRESS) {
1201 if (str_eq(flp->compress,S_BZIP2))
1202 - snprintf(MAXS(showtar),"%s -d < %s/%d.d | %s tvf -",
1203 + snprintf(showtar,sizeof(showtar)-1,"%s -d < %s/%d.d | %s tvf -",
1204 bzip2_bin,userspool,flp->id,tar_bin);
1206 - snprintf(MAXS(showtar),"%s -d < %s/%d.d | %s tvf -",
1207 + snprintf(showtar,sizeof(showtar)-1,"%s -d < %s/%d.d | %s tvf -",
1208 gzip_bin,userspool,flp->id,tar_bin);
1210 - snprintf(MAXS(showtar),"%s tvf %s/%d.d",tar_bin,userspool,flp->id);
1211 + snprintf(showtar,sizeof(showtar)-1,"%s tvf %s/%d.d",tar_bin,userspool,flp->id);
1214 /* sneak inside... */
1215 @@ -760,16 +760,16 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1217 switch (check_signature(flp,pgpring,0)) {
1219 - case 0: snprintf(MAXS(tmp),"no signature found for '%s'",nname);
1220 + case 0: snprintf(tmp,sizeof(tmp)-1,"no signature found for '%s'",nname);
1222 message(prg,'E',tmp);
1224 - case -1: snprintf(MAXS(tmp),"no public key found to check "
1225 + case -1: snprintf(tmp,sizeof(tmp)-1,"no public key found to check "
1226 "signature for '%s'",nname);
1228 message(prg,'E',tmp);
1230 - case -2: snprintf(MAXS(tmp),"bad signature for '%s'",nname);
1231 + case -2: snprintf(tmp,sizeof(tmp)-1,"bad signature for '%s'",nname);
1233 message(prg,'E',tmp);
1235 @@ -785,7 +785,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1237 /* show only the header? */
1239 - snprintf(MAXS(tmp),"%s/%d.h",userspool,flp->id);
1240 + snprintf(tmp,sizeof(tmp)-1,"%s/%d.h",userspool,flp->id);
1241 printf("%d) %s\n",flp->id,nname);
1242 inf=rfopen(tmp,"r");
1243 while (fgetl(line,inf)) printf("%s",line);
1244 @@ -799,10 +799,10 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1246 /* encrypted spool file? */
1247 if (flp->flags&F_CRYPT) {
1248 - snprintf(MAXS(cmd),"%s %s -f < %s/%d.d",pgp_bin,pgpvm,userspool,flp->id);
1249 + snprintf(cmd,sizeof(cmd)-1,"%s %s -f < %s/%d.d",pgp_bin,pgpvm,userspool,flp->id);
1250 if (vsystem(cmd)!=0) {
1252 - snprintf(MAXS(tmp),"cannot decrypt '%s' :",nname);
1253 + snprintf(tmp,sizeof(tmp)-1,"cannot decrypt '%s' :",nname);
1254 message(prg,'E',tmp);
1257 @@ -810,12 +810,12 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1258 /* compressed spool file? */
1259 else if (flp->flags&F_COMPRESS) {
1260 if (str_eq(flp->compress,S_BZIP2))
1261 - snprintf(MAXS(cmd),"%s -d < %s/%d.d",bzip2_bin,userspool,flp->id);
1262 + snprintf(cmd,sizeof(cmd)-1,"%s -d < %s/%d.d",bzip2_bin,userspool,flp->id);
1264 - snprintf(MAXS(cmd),"%s -d < %s/%d.d",gzip_bin,userspool,flp->id);
1265 + snprintf(cmd,sizeof(cmd)-1,"%s -d < %s/%d.d",gzip_bin,userspool,flp->id);
1266 if (vsystem(cmd)!=0 && !(flp->flags&F_TAR)) {
1268 - snprintf(MAXS(tmp),"cannot decompress '%s' :",nname);
1269 + snprintf(tmp,sizeof(tmp)-1,"cannot decompress '%s' :",nname);
1270 message(prg,'E',tmp);
1273 @@ -823,10 +823,10 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1274 else /* copy spool file to stdout */ {
1277 - snprintf(MAXS(tmp),"%s/%d.d",userspool,flp->id);
1278 + snprintf(tmp,sizeof(tmp)-1,"%s/%d.d",userspool,flp->id);
1279 if (fcopy(tmp,"",0)<0) {
1281 - snprintf(MAXS(tmp),"cannot read '%s'",nname);
1282 + snprintf(tmp,sizeof(tmp)-1,"cannot read '%s'",nname);
1283 message(prg,'E',tmp);
1286 @@ -865,9 +865,9 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1287 if (!quiet && checkfile(utf,fname,nname,sname,&overwrite)) return;
1290 - snprintf(MAXS(tmp),"%s/%d.d",userspool,flp->id);
1291 + snprintf(tmp,sizeof(tmp)-1,"%s/%d.d",userspool,flp->id);
1292 if (fcopy(tmp,fname,0666&~cmask)<0) {
1293 - snprintf(MAXS(tmp),"cannot receive '%s'",nname);
1294 + snprintf(tmp,sizeof(tmp)-1,"cannot receive '%s'",nname);
1296 message(prg,'E',tmp);
1298 @@ -877,7 +877,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1299 create_sigfile(flp->sign,fname,nname,&overwrite);
1301 if (!keep) delete_sf(flp,0);
1302 - snprintf(MAXS(tmp),"'%s' received",nname);
1303 + snprintf(tmp,sizeof(tmp)-1,"'%s' received",nname);
1304 message(prg,'I',tmp);
1307 @@ -886,14 +886,14 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1308 /* encrypted tar spool file? */
1309 if (flp->flags&F_CRYPT) {
1311 - snprintf(MAXS(cmd),"%s %s -f < %s/%d.d > %s",
1312 + snprintf(cmd,sizeof(cmd)-1,"%s %s -f < %s/%d.d > %s",
1313 pgp_bin,pgpvm,userspool,flp->id,tartmp);
1315 /* create temporary decrypted tar file */
1317 if (stat(tartmp,&finfo)<0 || finfo.st_size==0) {
1319 - snprintf(MAXS(tmp),"cannot decrypt '%s' :",nname);
1320 + snprintf(tmp,sizeof(tmp)-1,"cannot decrypt '%s' :",nname);
1321 message(prg,'E',tmp);
1324 @@ -914,15 +914,15 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1325 /* compressed, encrypted or normal tar file? */
1326 if (flp->flags&F_COMPRESS) {
1327 if (str_eq(flp->compress,S_BZIP2))
1328 - snprintf(MAXS(cmd),"%s -d < %s/%d.d | %s tvf -",
1329 + snprintf(cmd,sizeof(cmd)-1,"%s -d < %s/%d.d | %s tvf -",
1330 bzip2_bin,userspool,flp->id,tar_bin);
1332 - snprintf(MAXS(cmd),"%s -d < %s/%d.d | %s tvf -",
1333 + snprintf(cmd,sizeof(cmd)-1,"%s -d < %s/%d.d | %s tvf -",
1334 gzip_bin,userspool,flp->id,tar_bin);
1335 } else if (flp->flags&F_CRYPT) {
1336 - snprintf(MAXS(cmd),"%s tvf %s",tar_bin,tartmp);
1337 + snprintf(cmd,sizeof(cmd)-1,"%s tvf %s",tar_bin,tartmp);
1339 - snprintf(MAXS(cmd),"%s tvf %s/%d.d",tar_bin,userspool,flp->id);
1340 + snprintf(cmd,sizeof(cmd)-1,"%s tvf %s/%d.d",tar_bin,userspool,flp->id);
1343 /* open pipe to read tar file-info */
1344 @@ -949,15 +949,15 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1345 /* compressed, encrypted or normal tar file? */
1346 if (flp->flags&F_COMPRESS) {
1347 if (str_eq(flp->compress,S_BZIP2))
1348 - snprintf(MAXS(cmd),"%s -d < %s/%d.d | %s tf -",
1349 + snprintf(cmd,sizeof(cmd)-1,"%s -d < %s/%d.d | %s tf -",
1350 bzip2_bin,userspool,flp->id,tar_bin);
1352 - snprintf(MAXS(cmd),"%s -d < %s/%d.d | %s tf -",
1353 + snprintf(cmd,sizeof(cmd)-1,"%s -d < %s/%d.d | %s tf -",
1354 gzip_bin,userspool,flp->id,tar_bin);
1355 } else if (flp->flags&F_CRYPT) {
1356 - snprintf(MAXS(cmd),"%s tf %s",tar_bin,tartmp);
1357 + snprintf(cmd,sizeof(cmd)-1,"%s tf %s",tar_bin,tartmp);
1359 - snprintf(MAXS(cmd),"%s tf %s/%d.d",tar_bin,userspool,flp->id);
1360 + snprintf(cmd,sizeof(cmd)-1,"%s tf %s/%d.d",tar_bin,userspool,flp->id);
1363 /* open pipe to read tar file-info */
1364 @@ -1016,21 +1016,21 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1367 /* receive from tar file */
1368 - snprintf(MAXS(tmp),"receiving from archive '%s' :",nname);
1369 + snprintf(tmp,sizeof(tmp)-1,"receiving from archive '%s' :",nname);
1370 message(prg,'I',tmp);
1372 /* compressed, encrypted or normal tar file? */
1373 if (flp->flags&F_COMPRESS) {
1374 if (str_eq(flp->compress,S_BZIP2))
1375 - snprintf(MAXS(cmd),"%s -d < %s/%d.d | %s xvf - 2>%s",
1376 + snprintf(cmd,sizeof(cmd)-1,"%s -d < %s/%d.d | %s xvf - 2>%s",
1377 bzip2_bin,userspool,flp->id,tar_bin,error_log);
1379 - snprintf(MAXS(cmd),"%s -d < %s/%d.d | %s xvf - 2>%s",
1380 + snprintf(cmd,sizeof(cmd)-1,"%s -d < %s/%d.d | %s xvf - 2>%s",
1381 gzip_bin,userspool,flp->id,tar_bin,error_log);
1382 } else if (flp->flags&F_CRYPT)
1383 - snprintf(MAXS(cmd),"%s xvf %s 2>%s",tar_bin,tartmp,error_log);
1384 + snprintf(cmd,sizeof(cmd)-1,"%s xvf %s 2>%s",tar_bin,tartmp,error_log);
1386 - snprintf(MAXS(cmd),"%s xvf %s/%d.d 2>%s",
1387 + snprintf(cmd,sizeof(cmd)-1,"%s xvf %s/%d.d 2>%s",
1388 tar_bin,userspool,flp->id,error_log);
1390 /* receive tar archive and check for errors */
1391 @@ -1044,7 +1044,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1392 !simplematch(line,TAR": Could not create symlink*File exists*",1)) {
1395 - snprintf(MAXS(tmp),"errors while receive '%s' :",nname);
1396 + snprintf(tmp,sizeof(tmp)-1,"errors while receive '%s' :",nname);
1397 message(prg,'E',tmp);
1400 @@ -1055,7 +1055,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1402 /* was there an error with tar? */
1404 - snprintf(MAXS(tmp),"leaving '%s' in spool intact",nname);
1405 + snprintf(tmp,sizeof(tmp)-1,"leaving '%s' in spool intact",nname);
1406 message(prg,'I',tmp);
1409 @@ -1108,7 +1108,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1410 /* safety fallback: try to delete an old file with the same name */
1412 if (stat(fname,&finfo)==0) {
1413 - snprintf(MAXS(tmp),"cannot create '%s' : "
1414 + snprintf(tmp,sizeof(tmp)-1,"cannot create '%s' : "
1415 "file does already exist and is not deletable",fname);
1417 message(prg,'E',tmp);
1418 @@ -1119,16 +1119,16 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1419 if (preserve && flp->flags&F_CRYPT) {
1422 - snprintf(MAXS(tmp),"%s/%d.d",userspool,flp->id);
1423 + snprintf(tmp,sizeof(tmp)-1,"%s/%d.d",userspool,flp->id);
1424 if (fcopy(tmp,fname,0666&~cmask)<0) {
1425 - snprintf(MAXS(tmp),"cannot receive '%s'",nname);
1426 + snprintf(tmp,sizeof(tmp)-1,"cannot receive '%s'",nname);
1428 message(prg,'E',tmp);
1432 if ((flp->flags&F_SOURCE || flp->flags&F_TEXT) && !quiet) {
1433 - snprintf(MAXS(tmp),
1434 + snprintf(tmp,sizeof(tmp)-1,
1435 "'%s' has a SOURCE or TEXT attribute, you have to decode it "
1436 "after pgp-decrypting with: recode %s:"CHARSET" '%s'",
1437 nname,flp->charset,nname);
1438 @@ -1136,7 +1136,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1441 if (flp->flags&F_MIME && !quiet) {
1442 - snprintf(MAXS(tmp),
1443 + snprintf(tmp,sizeof(tmp)-1,
1444 "'%s' has the MIME attribute, you have to run it through"
1445 "metamail after pgp-decrypting",nname);
1446 message(prg,'W',tmp);
1447 @@ -1146,7 +1146,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1448 create_sigfile(flp->sign,fname,nname,&overwrite);
1450 if (!keep) delete_sf(flp,0);
1451 - snprintf(MAXS(tmp),"'%s' received",nname);
1452 + snprintf(tmp,sizeof(tmp)-1,"'%s' received",nname);
1453 message(prg,'I',tmp);
1456 @@ -1161,11 +1161,11 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1457 /* open pipe to uncompress or decrypt spool file */
1458 if (flp->flags&F_COMPRESS) {
1459 if (str_eq(flp->compress,S_BZIP2))
1460 - snprintf(MAXS(cmd),"%s -d < %s/%d.d",bzip2_bin,userspool,flp->id);
1461 + snprintf(cmd,sizeof(cmd)-1,"%s -d < %s/%d.d",bzip2_bin,userspool,flp->id);
1463 - snprintf(MAXS(cmd),"%s -d < %s/%d.d",gzip_bin,userspool,flp->id);
1464 + snprintf(cmd,sizeof(cmd)-1,"%s -d < %s/%d.d",gzip_bin,userspool,flp->id);
1465 } else if (flp->flags&F_CRYPT)
1466 - snprintf(MAXS(cmd),
1467 + snprintf(cmd,sizeof(cmd)-1,
1468 "%s %s -f < %s/%d.d",pgp_bin,pgpvm,userspool,flp->id);
1469 if ((pp=vpopen(cmd,"r")) == NULL) {
1470 message(prg,'E',"cannot open spool file for reading");
1471 @@ -1176,7 +1176,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1472 if (!(outf=rfopen(fname,"w"))) {
1475 - snprintf(MAXS(tmp),"cannot open '%s' for writing",nname);
1476 + snprintf(tmp,sizeof(tmp)-1,"cannot open '%s' for writing",nname);
1477 message(prg,'E',tmp);
1480 @@ -1192,12 +1192,12 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1482 } else /* binary format */ {
1484 - snprintf(MAXS(sfile),"%s/%d.d",userspool,flp->id);
1485 + snprintf(sfile,sizeof(sfile)-1,"%s/%d.d",userspool,flp->id);
1487 /* try to create destination file */
1488 /* open output file */
1489 if (!(outf=rfopen(fname,"w"))) {
1490 - snprintf(MAXS(tmp),"cannot open '%s' for writing",nname);
1491 + snprintf(tmp,sizeof(tmp)-1,"cannot open '%s' for writing",nname);
1492 message(prg,'E',tmp);
1495 @@ -1215,16 +1215,16 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1499 - snprintf(MAXS(tmpfile),"%sreceive-%d.tmp",tmp,(int)getpid());
1500 - snprintf(MAXS(tmp),"%s -d < %s > %s",bzip2_bin,sfile,tmpfile);
1501 + snprintf(tmpfile,sizeof(tmpfile)-1,"%sreceive-%d.tmp",tmp,(int)getpid());
1502 + snprintf(tmp,sizeof(tmp)-1,"%s -d < %s > %s",bzip2_bin,sfile,tmpfile);
1504 - snprintf(MAXS(tmp),"call to %s failed, cannot receive '%s'",
1505 + snprintf(tmp,sizeof(tmp)-1,"call to %s failed, cannot receive '%s'",
1507 message(prg,'E',tmp);
1510 if (rename(tmpfile,fname)<0) {
1511 - snprintf(MAXS(tmp),"cannot write to '%s'",nname);
1512 + snprintf(tmp,sizeof(tmp)-1,"cannot write to '%s'",nname);
1513 message(prg,'E',tmp);
1516 @@ -1239,7 +1239,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1518 if (spawn(sad,fname,cmask)<0) {
1520 - snprintf(MAXS(tmp),
1521 + snprintf(tmp,sizeof(tmp)-1,
1522 "call to %s failed, cannot receive '%s'",sad[0],nname);
1523 message(prg,'E',tmp);
1525 @@ -1252,10 +1252,10 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1526 /* encrypted spool file? */
1527 if (flp->flags&F_CRYPT) {
1529 - snprintf(MAXS(cmd),"%s %s -f < %s > '%s'",pgp_bin,pgpvm,sfile,fname);
1530 + snprintf(cmd,sizeof(cmd)-1,"%s %s -f < %s > '%s'",pgp_bin,pgpvm,sfile,fname);
1531 if (vsystem(cmd)!=0) {
1533 - snprintf(MAXS(tmp),"cannot receive '%s', pgp failed",nname);
1534 + snprintf(tmp,sizeof(tmp)-1,"cannot receive '%s', pgp failed",nname);
1535 message(prg,'E',tmp);
1538 @@ -1274,7 +1274,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1539 !(flp->flags&F_CRYPT)) {
1541 /* open input file */
1542 - snprintf(MAXS(sfile),"%s/%d.d",userspool,flp->id);
1543 + snprintf(sfile,sizeof(sfile)-1,"%s/%d.d",userspool,flp->id);
1544 if ((inf=rfopen(sfile,"r")) == NULL) {
1545 message(prg,'E',"cannot open spool file for reading");
1547 @@ -1282,7 +1282,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1549 /* open output file */
1550 if ((outf=rfopen(fname,"w")) == NULL) {
1551 - snprintf(MAXS(tmp),"cannot open '%s' for writing",nname);
1552 + snprintf(tmp,sizeof(tmp)-1,"cannot open '%s' for writing",nname);
1553 message(prg,'E',tmp);
1556 @@ -1298,9 +1298,9 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1557 } else /* binary file */ {
1560 - snprintf(MAXS(tmp),"%s/%d.d",userspool,flp->id);
1561 + snprintf(tmp,sizeof(tmp)-1,"%s/%d.d",userspool,flp->id);
1562 if (fcopy(tmp,fname,0666&~cmask)<0) {
1563 - snprintf(MAXS(tmp),"cannot receive '%s'",nname);
1564 + snprintf(tmp,sizeof(tmp)-1,"cannot receive '%s'",nname);
1566 message(prg,'E',tmp);
1568 @@ -1315,20 +1315,20 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1569 /* executable flag set? */
1570 if (flp->flags&F_EXE) chmod(fname,(S_IRWXU|S_IRWXG|S_IRWXO)&~cmask);
1572 - snprintf(MAXS(tmp),"'%s' received",nname);
1573 + snprintf(tmp,sizeof(tmp)-1,"'%s' received",nname);
1574 message(prg,'I',tmp);
1576 /* foreign character set in text file? */
1577 if ((flp->flags&F_TEXT) && !str_eq(flp->charset,CHARSET)) {
1579 /* call GNU recode */
1580 - snprintf(MAXS(tmp),"%s:"CHARSET,flp->charset);
1581 + snprintf(tmp,sizeof(tmp)-1,"%s:"CHARSET,flp->charset);
1586 if (spawn(sad,NULL,cmask)<0) {
1587 - snprintf(MAXS(tmp),
1588 + snprintf(tmp,sizeof(tmp)-1,
1589 "call to %s failed, cannot translate character set in '%s'",
1591 message(prg,'E',tmp);
1592 @@ -1348,7 +1348,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1594 /* metamail call allowed? */
1596 - snprintf(MAXS(tmp),
1597 + snprintf(tmp,sizeof(tmp)-1,
1598 "'%s' is a MIME file, you have to run it through metamail",
1600 message(prg,'I',tmp);
1601 @@ -1360,7 +1360,7 @@ void receive_sf(struct filelist *flp, char *pgpring, int header) {
1604 if (spawn(sad,NULL,cmask)<0) {
1605 - snprintf(MAXS(tmp),
1606 + snprintf(tmp,sizeof(tmp)-1,
1607 "call to %s failed, keeping local file '%s'",
1608 metamail_bin,nname);
1609 message(prg,'E',tmp);
1610 @@ -1403,7 +1403,7 @@ void crlf2lf(FILE *inf, FILE *outf, const char *fname, const char *nname) {
1613 if(fputc(c2,outf)==EOF) {
1614 - snprintf(MAXS(tmp),"cannot write to %s",nname);
1615 + snprintf(tmp,sizeof(tmp)-1,"cannot write to %s",nname);
1616 message(prg,'E',tmp);
1619 @@ -1415,7 +1415,7 @@ void crlf2lf(FILE *inf, FILE *outf, const char *fname, const char *nname) {
1622 if(fputc(c1,outf)==EOF) {
1623 - snprintf(MAXS(tmp),"cannot write to %s",nname);
1624 + snprintf(tmp,sizeof(tmp)-1,"cannot write to %s",nname);
1625 message(prg,'E',tmp);
1628 @@ -1426,7 +1426,7 @@ void crlf2lf(FILE *inf, FILE *outf, const char *fname, const char *nname) {
1630 /* write last char */
1631 if(fputc(c1,outf)==EOF) {
1632 - snprintf(MAXS(tmp),"cannot write to %s",nname);
1633 + snprintf(tmp,sizeof(tmp)-1,"cannot write to %s",nname);
1634 message(prg,'E',tmp);
1637 @@ -1607,8 +1607,8 @@ int create_sigfile(const char *sign, const char *fname, const char *nname,
1638 /* no pgp signature to save? */
1639 if (!*sign) return(0);
1641 - snprintf(MAXS(sigfile),"%s.sig",fname);
1642 - snprintf(MAXS(nsigfile),"%s.sig",nname);
1643 + snprintf(sigfile,sizeof(sigfile)-1,"%s.sig",fname);
1644 + snprintf(nsigfile,sizeof(nsigfile)-1,"%s.sig",nname);
1646 /* signature file does already exist? */
1647 while (stat(sigfile,&finfo)==0 && (*overwrite!='Y')) {
1648 @@ -1641,7 +1641,7 @@ int create_sigfile(const char *sign, const char *fname, const char *nname,
1649 /* safety fallback: try to delete an old file with the same name */
1651 if (stat(sigfile,&finfo)==0) {
1652 - snprintf(MAXS(tmp),"cannot create '%s' : "
1653 + snprintf(tmp,sizeof(tmp)-1,"cannot create '%s' : "
1654 "file does already exist and is not deletable",sigfile);
1656 message(prg,'E',tmp);
1657 @@ -1649,14 +1649,14 @@ int create_sigfile(const char *sign, const char *fname, const char *nname,
1660 if (!(outf=rfopen(sigfile,"w"))) {
1661 - snprintf(MAXS(tmp),"cannot create signature file '%s' ",nsigfile);
1662 + snprintf(tmp,sizeof(tmp)-1,"cannot create signature file '%s' ",nsigfile);
1663 message(prg,'E',tmp);
1667 fprintf(outf,"%s",sign);
1669 - snprintf(MAXS(tmp),"signature file '%s' created",nsigfile);
1670 + snprintf(tmp,sizeof(tmp)-1,"signature file '%s' created",nsigfile);
1671 message(prg,'I',tmp);
1674 @@ -1695,9 +1695,9 @@ int check_signature(struct filelist *flp, char *pgpring, int print) {
1675 if (str_eq(pgpring,".")) *pgpring=0;
1677 /* write signature file */
1678 - snprintf(MAXS(sigfile),"%s/%d.d.sig",userspool,flp->id);
1679 + snprintf(sigfile,sizeof(sigfile)-1,"%s/%d.d.sig",userspool,flp->id);
1680 if (!(outf=rfopen(sigfile,"w"))) {
1681 - snprintf(MAXS(tmp),"cannot write signature file %s",sigfile);
1682 + snprintf(tmp,sizeof(tmp)-1,"cannot write signature file %s",sigfile);
1683 message(prg,'E',tmp);
1686 @@ -1707,15 +1707,15 @@ int check_signature(struct filelist *flp, char *pgpring, int print) {
1687 /* build pgp options */
1689 if (access(pgpring,R_OK)<0) {
1690 - snprintf(MAXS(tmp),"cannot read pgp pub ring file %s",pgpring);
1691 + snprintf(tmp,sizeof(tmp)-1,"cannot read pgp pub ring file %s",pgpring);
1692 message(prg,'F',tmp);
1694 - snprintf(MAXS(pgpopt),"+batchmode=on +language=en +pubring=%s",pgpring);
1695 + snprintf(pgpopt,sizeof(pgpopt)-1,"+batchmode=on +language=en +pubring=%s",pgpring);
1697 - snprintf(MAXS(pgpopt),"+batchmode=on +language=en");
1698 + snprintf(pgpopt,sizeof(pgpopt)-1,"+batchmode=on +language=en");
1700 /* check signature file with pgp */
1701 - snprintf(MAXS(tmp),"%s %s %s 2>/dev/null",pgp_bin,pgpopt,sigfile);
1702 + snprintf(tmp,sizeof(tmp)-1,"%s %s %s 2>/dev/null",pgp_bin,pgpopt,sigfile);
1703 if (!(pp=vpopen(tmp,"r"))) {
1704 message(prg,'E',"cannot call pgp");
1706 @@ -1789,7 +1789,7 @@ void renumber (struct senderlist *sls) {
1709 if (chdir(userspool)<0) {
1710 - snprintf(MAXS(tmp),"cannot change to %s",userspool);
1711 + snprintf(tmp,sizeof(tmp)-1,"cannot change to %s",userspool);
1712 message(prg,'F',tmp);
1715 @@ -1816,20 +1816,20 @@ void renumber (struct senderlist *sls) {
1716 while (fscanf(lockf,"%d\n",&i)!=EOF) {
1717 if (i<min && i>lastused && i>nextfree) min=i;
1719 - snprintf(MAXS(ofile),"%d.h",min);
1720 + snprintf(ofile,sizeof(ofile)-1,"%d.h",min);
1721 for (i=nextfree; i<min; i++) {
1722 - snprintf(MAXS(nfile),"%d.h",i);
1723 + snprintf(nfile,sizeof(nfile)-1,"%d.h",i);
1724 if (stat(nfile,&finfo)<0 || finfo.st_size==0) {
1726 if (rename(ofile,nfile)<0) {
1727 - snprintf(MAXS(tmp),"cannot rename %s to %s",ofile,nfile);
1728 + snprintf(tmp,sizeof(tmp)-1,"cannot rename %s to %s",ofile,nfile);
1729 message(prg,'F',tmp);
1731 - snprintf(MAXS(nfile),"%d.d",i);
1732 - snprintf(MAXS(ofile),"%d.d",min);
1733 + snprintf(nfile,sizeof(nfile)-1,"%d.d",i);
1734 + snprintf(ofile,sizeof(ofile)-1,"%d.d",min);
1736 if (rename(ofile,nfile)<0) {
1737 - snprintf(MAXS(tmp),"cannot rename %s to %s",ofile,nfile);
1738 + snprintf(tmp,sizeof(tmp)-1,"cannot rename %s to %s",ofile,nfile);
1739 message(prg,'F',tmp);
1742 diff --git a/src/sendfile.c b/src/sendfile.c
1743 index 9f84393..09f9f52 100644
1744 --- a/src/sendfile.c
1745 +++ b/src/sendfile.c
1746 @@ -651,7 +651,7 @@ const char
1747 if (strstr(force_compress,"gzip")) compress=S_GZIP;
1748 if (strstr(force_compress,"bzip2")) compress=S_BZIP2;
1750 - snprintf(MAXS(tmp),"unsupported compression program %s",force_compress);
1751 + snprintf(tmp,sizeof(tmp)-1,"unsupported compression program %s",force_compress);
1753 message(prg,'F',tmp);
1755 @@ -660,7 +660,7 @@ const char
1756 } else if (*compress) {
1759 - snprintf(MAXS(tmp),"%s --help 2>&1",bzip2_bin);
1760 + snprintf(tmp,sizeof(tmp)-1,"%s --help 2>&1",bzip2_bin);
1761 if ((pp=popen(tmp,"r"))) {
1762 while (fgetl(line,pp)) {
1763 if (strstr(line,"usage:")) {
1764 @@ -678,7 +678,7 @@ const char
1766 if (!*zprg) *bzip2_bin=0;
1768 - snprintf(MAXS(tmp),"%s --help 2>&1",gzip_bin);
1769 + snprintf(tmp,sizeof(tmp)-1,"%s --help 2>&1",gzip_bin);
1770 if ((pp=popen(tmp,"r"))) {
1771 while (fgetl(line,pp)) if (strstr(line,"usage:")) break;
1773 @@ -719,7 +719,7 @@ const char
1774 if (str_eq(host,"127.0.0.1") || str_eq(host,"0")) strcpy(host,localhost);
1777 - snprintf(MAXS(cmd),"%s %s ",argv[0],aopt);
1778 + snprintf(cmd,sizeof(cmd)-1,"%s %s ",argv[0],aopt);
1779 for(i=1;i<argc-1;i++) {
1781 strcat(cmd,argv[i]);
1782 @@ -764,7 +764,7 @@ const char
1786 - snprintf(MAXS(pgprid),"%s@%s",recipient,host);
1787 + snprintf(pgprid,sizeof(pgprid)-1,"%s@%s",recipient,host);
1789 /* is there a recipient id? */
1791 @@ -796,7 +796,7 @@ const char
1792 /* is there a signature id? */
1794 if (*pop=='=') pop++;
1795 - snprintf(MAXS(pgpsign),"-u '%s",pop);
1796 + snprintf(pgpsign,sizeof(pgpsign)-1,"-u '%s",pop);
1798 /* cut off any more options */
1799 if ((cp=strchr(pgpsign,'\n'))) {
1800 @@ -813,7 +813,7 @@ const char
1802 /* wrong pgp options */
1804 - snprintf(MAXS(tmp),"wrong pgp option, see 'man %s'",prg);
1805 + snprintf(tmp,sizeof(tmp)-1,"wrong pgp option, see 'man %s'",prg);
1806 message(prg,'F',tmp);
1809 @@ -821,13 +821,13 @@ const char
1812 /* set various file names */
1813 - snprintf(MAXS(userspool),SPOOL"/%s",pw_name);
1814 - snprintf(MAXS(outlogtmp),"%s/.sendfile_%d.log",userspool,pid);
1815 - snprintf(MAXS(tartmp),"%s/sendfile.tar",tmpdir);
1816 - snprintf(MAXS(ziptmp),"%s/sendfile.zip",tmpdir);
1817 - snprintf(MAXS(pgptmp),"%s/sendfile.pgp",tmpdir);
1818 - snprintf(MAXS(texttmp),"%s/sendfile.txt",tmpdir);
1819 - snprintf(MAXS(stdintmp),"%s/sendfile.tmp",tmpdir);
1820 + snprintf(userspool,sizeof(userspool)-1,SPOOL"/%s",pw_name);
1821 + snprintf(outlogtmp,sizeof(outlogtmp)-1,"%s/.sendfile_%d.log",userspool,pid);
1822 + snprintf(tartmp,sizeof(tartmp)-1,"%s/sendfile.tar",tmpdir);
1823 + snprintf(ziptmp,sizeof(ziptmp)-1,"%s/sendfile.zip",tmpdir);
1824 + snprintf(pgptmp,sizeof(pgptmp)-1,"%s/sendfile.pgp",tmpdir);
1825 + snprintf(texttmp,sizeof(texttmp)-1,"%s/sendfile.txt",tmpdir);
1826 + snprintf(stdintmp,sizeof(stdintmp)-1,"%s/sendfile.tmp",tmpdir);
1828 /* where are the files/directories ? */
1830 @@ -845,11 +845,11 @@ const char
1832 printf("%s\n",userspool);
1834 - snprintf(MAXS(tmp),"the user spool directory is: %s",userspool);
1835 + snprintf(tmp,sizeof(tmp)-1,"the user spool directory is: %s",userspool);
1836 message(prg,'I',tmp);
1839 - snprintf(MAXS(tmp),"%s is an unknown -W argument",where);
1840 + snprintf(tmp,sizeof(tmp)-1,"%s is an unknown -W argument",where);
1842 message(prg,'E',tmp);
1843 if (quiet<2) message(prg,'I',"you may specify -W=config, -W=spool, or "
1844 @@ -865,27 +865,27 @@ const char
1847 if (stat(tartmp,&finfo)==0) {
1848 - snprintf(MAXS(tmp),
1849 + snprintf(tmp,sizeof(tmp)-1,
1850 "tmp-file %s does already exist and cannot be deleted",tartmp);
1851 message(prg,'F',tmp);
1853 if (stat(ziptmp,&finfo)==0) {
1854 - snprintf(MAXS(tmp),
1855 + snprintf(tmp,sizeof(tmp)-1,
1856 "tmp-file %s does already exist and cannot be deleted",ziptmp);
1857 message(prg,'F',tmp);
1859 if (stat(texttmp,&finfo)==0) {
1860 - snprintf(MAXS(tmp),
1861 + snprintf(tmp,sizeof(tmp)-1,
1862 "tmp-file %s does already exist and cannot be deleted",texttmp);
1863 message(prg,'F',tmp);
1865 if (stat(pgptmp,&finfo)==0) {
1866 - snprintf(MAXS(tmp),
1867 + snprintf(tmp,sizeof(tmp)-1,
1868 "tmp-file %s does already exist and cannot be deleted",pgptmp);
1869 message(prg,'F',tmp);
1871 if (stat(stdintmp,&finfo)==0) {
1872 - snprintf(MAXS(tmp),
1873 + snprintf(tmp,sizeof(tmp)-1,
1874 "tmp-file %s does already exist and cannot be deleted",stdintmp);
1875 message(prg,'F',tmp);
1877 @@ -954,7 +954,7 @@ const char
1878 /* set tcp packet length */
1879 if (packet_size<1) packet_size=PACKET;
1880 if (verbose && !spool && !del) {
1881 - snprintf(MAXS(tmp),"packet size = %d bytes",packet_size);
1882 + snprintf(tmp,sizeof(tmp)-1,"packet size = %d bytes",packet_size);
1883 message(prg,'I',tmp);
1886 @@ -970,14 +970,14 @@ const char
1888 /* write stdin to tmp-file */
1889 if (!(outf=rfopen(stdintmp,"w"))) {
1890 - snprintf(MAXS(tmp),"cannot open tmp-file %s",stdintmp);
1891 + snprintf(tmp,sizeof(tmp)-1,"cannot open tmp-file %s",stdintmp);
1892 message(prg,'F',tmp);
1894 /* while ((ch=getchar())!=EOF) putc(ch,outf); */
1895 while ((bytes=read(fileno(stdin),iobuf,IOB))) {
1896 if (bytes<0) message(prg,'F',"error while reading from stdin");
1897 if (write(fileno(outf),iobuf,bytes)!=bytes) {
1898 - snprintf(MAXS(tmp),"error while writing stdin to %s",stdintmp);
1899 + snprintf(tmp,sizeof(tmp)-1,"error while writing stdin to %s",stdintmp);
1900 message(prg,'F',tmp);
1903 @@ -1022,13 +1022,13 @@ const char
1904 /* does the outgoing spool exist? */
1905 strcpy(outgoing,SPOOL"/OUTGOING");
1906 if (stat(outgoing,&finfo)<0 || !S_ISDIR(finfo.st_mode)) {
1907 - snprintf(MAXS(tmp),"spool directory %s does not exist",outgoing);
1908 + snprintf(tmp,sizeof(tmp)-1,"spool directory %s does not exist",outgoing);
1909 message(prg,'F',tmp);
1912 /* and does it have the correct protection? */
1913 if (!((finfo.st_mode&S_ISVTX) && (finfo.st_mode&S_IRWXO))) {
1914 - snprintf(MAXS(tmp),
1915 + snprintf(tmp,sizeof(tmp)-1,
1916 "spool directory %s has wrong protection (must have 1777)",
1918 message(prg,'F',tmp);
1919 @@ -1045,19 +1045,19 @@ const char
1921 /* does the spool directory exist? */
1922 if (chdir(userspool)<0) {
1923 - snprintf(MAXS(tmp),"cannot access spool directory %s",userspool);
1924 + snprintf(tmp,sizeof(tmp)-1,"cannot access spool directory %s",userspool);
1925 message(prg,'F',tmp);
1928 /* main loop over the spool file names */
1929 for (fn=optind; fn<argc-1; fn++) {
1930 - snprintf(MAXS(sdfn),"%s.d",argv[fn]);
1931 - snprintf(MAXS(shfn),"%s.h",argv[fn]);
1932 - if (info) snprintf(MAXS(tinfo),"#%d/%d: ",fn-optind+1,argc-optind-1);
1933 + snprintf(sdfn,sizeof(sdfn)-1,"%s.d",argv[fn]);
1934 + snprintf(shfn,sizeof(shfn)-1,"%s.h",argv[fn]);
1935 + if (info) snprintf(tinfo,sizeof(tinfo)-1,"#%d/%d: ",fn-optind+1,argc-optind-1);
1937 /* try to open spool header file */
1938 if (!(shf=rfopen(shfn,"r"))) {
1939 - snprintf(MAXS(tmp),"cannot open spool file #%s",argv[fn]);
1940 + snprintf(tmp,sizeof(tmp)-1,"cannot open spool file #%s",argv[fn]);
1941 message(prg,'E',tmp);
1944 @@ -1091,7 +1091,7 @@ const char
1945 strcpy(comment,strchr(line,' ')+1);
1946 if ((cp=strchr(comment,' '))) {
1948 - snprintf(MAXS(tmp),"%s+ACA-(%s)",comment,cp+1);
1949 + snprintf(tmp,sizeof(tmp)-1,"%s+ACA-(%s)",comment,cp+1);
1950 strcpy(comment,tmp);
1953 @@ -1129,7 +1129,7 @@ const char
1954 if (str_beq(reply,"200 ")) break;
1957 - snprintf(MAXS(tmp),"cannot send %s : %s",file,reply+4);
1958 + snprintf(tmp,sizeof(tmp)-1,"cannot send %s : %s",file,reply+4);
1960 message(prg,'E',tmp);
1962 @@ -1142,15 +1142,15 @@ const char
1963 /* recompress spool file */
1964 if (str_eq(type,S_BZIP2)) {
1965 if (str_eq(compress,S_GZIP))
1966 - snprintf(MAXS(cmd),"%s -d <%s|%s>%s",BZIP2,sdfn,GZIP,ziptmp);
1967 + snprintf(cmd,sizeof(cmd)-1,"%s -d <%s|%s>%s",BZIP2,sdfn,GZIP,ziptmp);
1969 - snprintf(MAXS(cmd),"%s -d < %s > %s",BZIP2,sdfn,ziptmp);
1970 + snprintf(cmd,sizeof(cmd)-1,"%s -d < %s > %s",BZIP2,sdfn,ziptmp);
1972 - snprintf(MAXS(cmd),"%s -dc %s > %s",GZIP,sdfn,ziptmp);
1973 + snprintf(cmd,sizeof(cmd)-1,"%s -dc %s > %s",GZIP,sdfn,ziptmp);
1975 /* execute shell-command and close spool header file on error */
1977 - snprintf(MAXS(tmp),"cannot recompress spool file #%s",argv[fn]);
1978 + snprintf(tmp,sizeof(tmp)-1,"cannot recompress spool file #%s",argv[fn]);
1979 message(prg,'E',tmp);
1982 @@ -1169,9 +1169,9 @@ const char
1983 /* is there already a comment line? */
1984 if (str_beq(line,"COMMENT")) {
1986 - snprintf(MAXS(line),"%s+AA0ACg-%s",comment,redirect);
1987 + snprintf(line,sizeof(line)-1,"%s+AA0ACg-%s",comment,redirect);
1989 - snprintf(MAXS(tmp),
1990 + snprintf(tmp,sizeof(tmp)-1,
1991 "%s+AA0ACg-forward+ACA-from+ACA-%s",line,comment);
1994 @@ -1200,9 +1200,9 @@ const char
1995 /* send comment if not already done */
1997 iso2utf(tmp,"forward from ");
1998 - snprintf(MAXS(line),"COMMENT %s%s",tmp,comment);
1999 + snprintf(line,sizeof(line)-1,"COMMENT %s%s",tmp,comment);
2001 - snprintf(MAXS(tmp),"\r\n%s",redirect);
2002 + snprintf(tmp,sizeof(tmp)-1,"\r\n%s",redirect);
2003 iso2utf(comment,tmp);
2004 strcat(line,comment);
2006 @@ -1215,12 +1215,12 @@ const char
2007 /* check the file size */
2008 if (stat(ziptmp,&finfo)==0) {
2010 - snprintf(MAXS(sizes),"%lld %lld",size,orgsize);
2011 - snprintf(MAXS(line),"SIZE %s",sizes);
2012 + snprintf(sizes,sizeof(sizes)-1,"%lld %lld",size,orgsize);
2013 + snprintf(line,sizeof(line)-1,"SIZE %s",sizes);
2014 sendcommand(sockfd,line,NULL);
2016 if (stat(sdfn,&finfo)<0 || size!=finfo.st_size) {
2017 - snprintf(MAXS(tmp),
2018 + snprintf(tmp,sizeof(tmp)-1,
2019 "spool file #%s has wrong size count - ignored",argv[fn]);
2021 message(prg,'E',tmp);
2022 @@ -1302,7 +1302,7 @@ const char
2026 - snprintf(MAXS(tmp),"shell-call: %s",cmd);
2027 + snprintf(tmp,sizeof(tmp)-1,"shell-call: %s",cmd);
2028 message(prg,'I',tmp);
2031 @@ -1331,9 +1331,9 @@ const char
2032 /* compress tar-archive */
2033 if (!quiet) printf("compressing... \r");
2035 - snprintf(MAXS(cmd),"%s < %s > %s",zprg,tartmp,ziptmp);
2036 + snprintf(cmd,sizeof(cmd)-1,"%s < %s > %s",zprg,tartmp,ziptmp);
2038 - snprintf(MAXS(tmp),"shell-call: %s",cmd);
2039 + snprintf(tmp,sizeof(tmp)-1,"shell-call: %s",cmd);
2040 message(prg,'I',tmp);
2042 if (vsystem(cmd)) message(prg,'F',"cannot compress archive file");
2043 @@ -1350,7 +1350,7 @@ const char
2044 /* get the file size */
2045 if (stat(file,&finfo)<0) message(prg,'F',"cannot access tmp file");
2047 - snprintf(MAXS(sizes),"%lld %lld",size,orgsize);
2048 + snprintf(sizes,sizeof(sizes)-1,"%lld %lld",size,orgsize);
2050 /* write to outgoing spool? */
2052 @@ -1360,9 +1360,9 @@ const char
2054 /* create correct to-string */
2055 if (strchr(argv[argc-1],'*'))
2056 - snprintf(MAXS(to),"%s",argv[argc-1]);
2057 + snprintf(to,sizeof(to)-1,"%s",argv[argc-1]);
2059 - snprintf(MAXS(to),"%s@%s",recipient,host);
2060 + snprintf(to,sizeof(to)-1,"%s@%s",recipient,host);
2062 /* search for file in outgoing spool */
2063 for (hlp=hls; hlp; hlp=hlp->next) {
2064 @@ -1372,7 +1372,7 @@ const char
2065 if (simplematch(oflp->fname,utf_name,0)) {
2067 /* matching recipient? */
2068 - snprintf(MAXS(rto),"%s@%s",oflp->to,hlp->host);
2069 + snprintf(rto,sizeof(rto)-1,"%s@%s",oflp->to,hlp->host);
2070 if (simplematch(rto,to,0)) {
2071 unlink(oflp->oshfn);
2072 oflp->oshfn[strlen(oflp->oshfn)-1]='d';
2073 @@ -1406,7 +1406,7 @@ const char
2075 } else { /* send header lines */
2077 - snprintf(MAXS(tmp),"FILE %s",utf_name);
2078 + snprintf(tmp,sizeof(tmp)-1,"FILE %s",utf_name);
2079 /* deactivate exit on 4xx error to test for timeout */
2081 sendcommand(sockfd,tmp,reply);
2082 @@ -1415,7 +1415,7 @@ const char
2083 /* saft server still online? (check timeout) */
2084 if (str_beq(reply,"429 ")) {
2085 sockfd=saft_connect("file",recipient,user,host,redirect);
2086 - snprintf(MAXS(tmp),"FILE %s",utf_name);
2087 + snprintf(tmp,sizeof(tmp)-1,"FILE %s",utf_name);
2088 sendcommand(sockfd,tmp,reply);
2091 @@ -1424,14 +1424,14 @@ const char
2094 if (str_beq(reply,"200 ")) sendcommand(sockfd,"DEL",reply);
2095 - snprintf(MAXS(tmp),"FILE %s",utf_name);
2096 + snprintf(tmp,sizeof(tmp)-1,"FILE %s",utf_name);
2097 sendcommand(sockfd,tmp,reply);
2100 if (str_eq(compress,S_GZIP))
2101 - snprintf(MAXS(tmp),"TYPE BINARY COMPRESSED");
2102 + snprintf(tmp,sizeof(tmp)-1,"TYPE BINARY COMPRESSED");
2104 - snprintf(MAXS(tmp),"TYPE BINARY COMPRESSED=%s",compress);
2105 + snprintf(tmp,sizeof(tmp)-1,"TYPE BINARY COMPRESSED=%s",compress);
2106 sendcommand(sockfd,tmp,reply);
2107 if (!test && !str_beq(reply,"200 ") && quiet<2) {
2109 @@ -1448,7 +1448,7 @@ const char
2110 if (!test && !str_beq(reply,"200 ") && quiet<2)
2111 message(prg,'W',"remote site does not support binary files");
2113 - snprintf(MAXS(tmp),"SIZE %s",sizes);
2114 + snprintf(tmp,sizeof(tmp)-1,"SIZE %s",sizes);
2115 sendheader(sockfd,tmp);
2116 sendcommand(sockfd,"ATTR TAR",reply);
2117 if (!test && !str_beq(reply,"200 ") && quiet<2) {
2118 @@ -1463,7 +1463,7 @@ const char
2119 if (*comment) strcat(line,comment);
2122 - snprintf(MAXS(tmp),"%s\r\n%s",line,redirect);
2123 + snprintf(tmp,sizeof(tmp)-1,"%s\r\n%s",line,redirect);
2126 strcpy(line,redirect);
2127 @@ -1472,7 +1472,7 @@ const char
2129 fprintf(oshf,"COMMENT\t%s\n",tmp);
2131 - snprintf(MAXS(line),"COMMENT %s",tmp);
2132 + snprintf(line,sizeof(line)-1,"COMMENT %s",tmp);
2133 sendcommand(sockfd,line,NULL);
2136 @@ -1515,7 +1515,7 @@ const char
2138 /* main loop over the file names */
2139 for (fn=optind; fn<argc-1; fn++) {
2140 - if (info) snprintf(MAXS(tinfo),"#%d/%d: ",fn-optind+1,argc-optind-1);
2141 + if (info) snprintf(tinfo,sizeof(tinfo)-1,"#%d/%d: ",fn-optind+1,argc-optind-1);
2143 /* file from stdin? */
2145 @@ -1549,9 +1549,9 @@ const char
2147 /* create correct to-string */
2148 if (strchr(argv[argc-1],'*'))
2149 - snprintf(MAXS(to),"%s",argv[argc-1]);
2150 + snprintf(to,sizeof(to)-1,"%s",argv[argc-1]);
2152 - snprintf(MAXS(to),"%s@%s",recipient,host);
2153 + snprintf(to,sizeof(to)-1,"%s@%s",recipient,host);
2155 /* search for file in outgoing spool */
2156 for (hlp=hls; hlp; hlp=hlp->next) {
2157 @@ -1561,7 +1561,7 @@ const char
2158 if (simplematch(oflp->fname,utf_name,0)) {
2160 /* matching recipient? */
2161 - snprintf(MAXS(rto),"%s@%s",oflp->to,hlp->host);
2162 + snprintf(rto,sizeof(rto)-1,"%s@%s",oflp->to,hlp->host);
2163 if (simplematch(rto,to,0)) {
2164 unlink(oflp->oshfn);
2165 oflp->oshfn[strlen(oflp->oshfn)-1]='d';
2166 @@ -1569,7 +1569,7 @@ const char
2169 utf2iso(0,NULL,file,NULL,oflp->fname);
2170 - snprintf(MAXS(tmp),
2171 + snprintf(tmp,sizeof(tmp)-1,
2172 "deleted from outgoing spool: '%s' for %s ",
2174 if (quiet<2) message(prg,'I',tmp);
2175 @@ -1595,7 +1595,7 @@ const char
2176 } else /* send header lines */ {
2178 /* send file name */
2179 - snprintf(MAXS(tmp),"FILE %s",utf_name);
2180 + snprintf(tmp,sizeof(tmp)-1,"FILE %s",utf_name);
2181 sendcommand(sockfd,tmp,reply);
2182 if (!test && !str_beq(reply,"200 ") && quiet<2)
2183 message(prg,'W',"remote site does not support file names");
2184 @@ -1606,7 +1606,7 @@ const char
2185 if (sendheader(sockfd,"DEL")) {
2186 if (quiet<2) message(prg,'W',"remote site cannot delete files");
2188 - snprintf(MAXS(tmp),"'%s' deleted",iso_name);
2189 + snprintf(tmp,sizeof(tmp)-1,"'%s' deleted",iso_name);
2190 if (quiet<2) message(prg,'I',tmp);
2193 @@ -1616,7 +1616,7 @@ const char
2195 /* is the file readable? */
2196 if (stat(file,&finfo)<0) {
2197 - snprintf(MAXS(tmp),"cannot access '%s'",file);
2198 + snprintf(tmp,sizeof(tmp)-1,"cannot access '%s'",file);
2199 message(prg,'E',tmp);
2202 @@ -1628,7 +1628,7 @@ const char
2203 /* is it a regular file? */
2204 if (!S_ISREG(finfo.st_mode)) {
2206 - snprintf(MAXS(tmp),"%s is not a regular file, skipping",file);
2207 + snprintf(tmp,sizeof(tmp)-1,"%s is not a regular file, skipping",file);
2208 message(prg,'E',tmp);
2211 @@ -1659,7 +1659,7 @@ const char
2212 inf=rfopen(file,"r");
2213 outf=rfopen(texttmp,"w");
2215 - snprintf(MAXS(tmp),"cannot open '%s'",file);
2216 + snprintf(tmp,sizeof(tmp)-1,"cannot open '%s'",file);
2217 message(prg,'E',tmp);
2220 @@ -1703,7 +1703,7 @@ const char
2221 for (n=0;do_compress && *cft[n];n++) {
2223 /* is this file a not compressible one? */
2224 - snprintf(MAXS(tmp),"*%s*",cft[n]);
2225 + snprintf(tmp,sizeof(tmp)-1,"*%s*",cft[n]);
2226 if (simplematch(ftype,tmp,1)) do_compress=0;
2229 @@ -1715,13 +1715,13 @@ const char
2230 /* compress tmp-file */
2231 if (!quiet) printf("compressing... \r");
2233 - snprintf(MAXS(cmd),"%s < '%s' > %s",zprg,file,ziptmp);
2234 + snprintf(cmd,sizeof(cmd)-1,"%s < '%s' > %s",zprg,file,ziptmp);
2236 - snprintf(MAXS(tmp),"shell-call: %s",strchr(cmd,';')+1);
2237 + snprintf(tmp,sizeof(tmp)-1,"shell-call: %s",strchr(cmd,';')+1);
2238 message(prg,'I',tmp);
2241 - snprintf(MAXS(tmp),"cannot compress %s",file);
2242 + snprintf(tmp,sizeof(tmp)-1,"cannot compress %s",file);
2243 message(prg,'E',tmp);
2246 @@ -1743,7 +1743,7 @@ const char
2247 /* get the file size */
2248 if (stat(file,&finfo)<0) message(prg,'F',"cannot access tmp file");
2250 - snprintf(MAXS(sizes),"%lld %lld",size,orgsize);
2251 + snprintf(sizes,sizeof(sizes)-1,"%lld %lld",size,orgsize);
2253 printf("DEBUG: size=%lld orgsize=%lld sizes=%s\n",size,orgsize,sizes);
2255 @@ -1781,22 +1781,22 @@ const char
2258 if (str_eq(compress,S_GZIP))
2259 - snprintf(MAXS(line),"TYPE %s COMPRESSED",type);
2260 + snprintf(line,sizeof(line)-1,"TYPE %s COMPRESSED",type);
2262 - snprintf(MAXS(line),"TYPE %s COMPRESSED=%s",type,compress);
2263 + snprintf(line,sizeof(line)-1,"TYPE %s COMPRESSED=%s",type,compress);
2264 } else if (pgpcrypt)
2265 - snprintf(MAXS(line),"TYPE %s CRYPTED",type);
2266 + snprintf(line,sizeof(line)-1,"TYPE %s CRYPTED",type);
2268 - snprintf(MAXS(line),"TYPE %s",type);
2269 + snprintf(line,sizeof(line)-1,"TYPE %s",type);
2270 sendcommand(sockfd,line,reply);
2271 if (!test && !str_beq(reply,"200 ") && quiet<2) {
2273 - snprintf(MAXS(tmp),"remote site does not support file of %s",line);
2274 + snprintf(tmp,sizeof(tmp)-1,"remote site does not support file of %s",line);
2275 message(prg,'F',tmp);
2277 - snprintf(MAXS(tmp),"SIZE %s",sizes);
2278 + snprintf(tmp,sizeof(tmp)-1,"SIZE %s",sizes);
2279 sendheader(sockfd,tmp);
2280 - snprintf(MAXS(tmp),"DATE %s",date);
2281 + snprintf(tmp,sizeof(tmp)-1,"DATE %s",date);
2282 if (sendheader(sockfd,tmp) && quiet<2)
2283 message(prg,'W',"remote site does not support dates");
2285 @@ -1811,7 +1811,7 @@ const char
2286 if (*comment) strcat(line,comment);
2289 - snprintf(MAXS(tmp),"%s\r\n%s",line,redirect);
2290 + snprintf(tmp,sizeof(tmp)-1,"%s\r\n%s",line,redirect);
2293 strcpy(line,redirect);
2294 @@ -1820,7 +1820,7 @@ const char
2296 fprintf(oshf,"COMMENT\t%s\n",tmp);
2298 - snprintf(MAXS(line),"COMMENT %s",tmp);
2299 + snprintf(line,sizeof(line)-1,"COMMENT %s",tmp);
2300 sendcommand(sockfd,line,NULL);
2303 @@ -1880,15 +1880,15 @@ const char
2304 if (tsize && info && tfn>1 && quiet<2) {
2305 thruput=tsize*1000/tttime;
2306 if (tsize/1024>9999)
2307 - snprintf(MAXS(tmp),"%d files sent with %.1f MB",tfn,tsize/1024/1024);
2308 + snprintf(tmp,sizeof(tmp)-1,"%d files sent with %.1f MB",tfn,tsize/1024/1024);
2309 else if (tsize>9999)
2310 - snprintf(MAXS(tmp),"%d files sent with %.1f kB",tfn,tsize/1024);
2311 + snprintf(tmp,sizeof(tmp)-1,"%d files sent with %.1f kB",tfn,tsize/1024);
2313 - snprintf(MAXS(tmp),"%d files sent with %d byte",tfn,(int)tsize);
2314 + snprintf(tmp,sizeof(tmp)-1,"%d files sent with %d byte",tfn,(int)tsize);
2316 - snprintf(MAXS(line),"%s at %.1f kB/s",tmp,thruput/1024);
2317 + snprintf(line,sizeof(line)-1,"%s at %.1f kB/s",tmp,thruput/1024);
2319 - snprintf(MAXS(line),"%s at %d byte/s",tmp,(int)thruput);
2320 + snprintf(line,sizeof(line)-1,"%s at %d byte/s",tmp,(int)thruput);
2321 message("",'I',line);
2324 @@ -1952,7 +1952,7 @@ void cleanup() {
2325 if (str_beq(reply,"220 ") && strstr(reply,"SAFT")) {
2327 /* send LOG command */
2328 - snprintf(MAXS(line),"LOG %s %s",pw_name,outlogtmp);
2329 + snprintf(line,sizeof(line)-1,"LOG %s %s",pw_name,outlogtmp);
2330 sock_putline(sockfd,line);
2331 sock_getline(sockfd,reply);
2333 @@ -1981,7 +1981,7 @@ void cleanup() {
2334 if (str_beq(reply,"220 ") && strstr(reply,"SAFT")) {
2336 /* send LOG command */
2337 - snprintf(MAXS(line),"LOG %s %s",pw_name,outlogtmp);
2338 + snprintf(line,sizeof(line)-1,"LOG %s %s",pw_name,outlogtmp);
2339 sock_putline(sockfd,line);
2340 sock_getline(sockfd,reply);
2342 @@ -2033,7 +2033,7 @@ void pgp_encrypt(int pgpcrypt, char *pgprid, char *file) {
2344 /* look for matching pgp-IDs */
2345 if (strlen(pgprid)>1) {
2346 - snprintf(MAXS(cmd),"%s -kvf %s > %s 2>/dev/null",pgp_bin,pgprid,pgptmp);
2347 + snprintf(cmd,sizeof(cmd)-1,"%s -kvf %s > %s 2>/dev/null",pgp_bin,pgprid,pgptmp);
2349 if (stat(pgptmp,&finfo)<0 || finfo.st_size==0 || !(inf=rfopen(pgptmp,"r"))) {
2351 @@ -2044,7 +2044,7 @@ void pgp_encrypt(int pgpcrypt, char *pgprid, char *file) {
2352 if ((cp=strchr(line,'.'))) *cp=0;
2353 if (!str_eq(line,"1 matching key found")) {
2355 - snprintf(MAXS(line),"ambigous pgp-ID '%s'",pgprid);
2356 + snprintf(line,sizeof(line)-1,"ambigous pgp-ID '%s'",pgprid);
2357 message(prg,'W',line);
2358 inf=rfopen(pgptmp,"r");
2359 while (fgetl(line,inf)) printf("%s",line);
2360 @@ -2057,7 +2057,7 @@ void pgp_encrypt(int pgpcrypt, char *pgprid, char *file) {
2362 /* pgp needs user input? */
2363 if (pgpcrypt=='c' || !*pgprid) {
2364 - snprintf(MAXS(cmd),"%s +armor=off -f%c < %s > %s",
2365 + snprintf(cmd,sizeof(cmd)-1,"%s +armor=off -f%c < %s > %s",
2366 pgp_bin,pgpcrypt,shell_quote(file),pgptmp);
2367 if (vsystem(cmd) || stat(pgptmp,&finfo)<0 || finfo.st_size==0) {
2369 @@ -2067,7 +2067,7 @@ void pgp_encrypt(int pgpcrypt, char *pgprid, char *file) {
2371 /* pgp needs no user input */
2373 - snprintf(MAXS(cmd),"%s +armor=off -fe %s < %s > %s 2>/dev/null",
2374 + snprintf(cmd,sizeof(cmd)-1,"%s +armor=off -fe %s < %s > %s 2>/dev/null",
2375 pgp_bin,pgprid,shell_quote(file),pgptmp);
2376 if (vsystem(cmd) || stat(pgptmp,&finfo)<0 || finfo.st_size==0) {
2378 @@ -2102,10 +2102,10 @@ void pgp_sign(const char *pgpsign, const char *infile, int sockfd) {
2380 if (!quiet && !pgppass) message(prg,'I',"call to pgp...");
2382 - snprintf(MAXS(cmd),"%s %s -fsba %s < %s",
2383 + snprintf(cmd,sizeof(cmd)-1,"%s %s -fsba %s < %s",
2384 pgp_bin,pgpvm,pgpsign,shell_quote(infile));
2386 - snprintf(MAXS(tmp),"shell-call: %s",cmd);
2387 + snprintf(tmp,sizeof(tmp)-1,"shell-call: %s",cmd);
2388 message(prg,'I',tmp);
2390 if (!(pipe=popen(cmd,"r"))) message(prg,'F',"call to pgp (signature) failed");
2391 @@ -2124,7 +2124,7 @@ void pgp_sign(const char *pgpsign, const char *infile, int sockfd) {
2392 if (check!=3) message(prg,'F',"call to pgp (signature) failed");
2395 - snprintf(MAXS(sign),"SIGN %s",tmp);
2396 + snprintf(sign,sizeof(sign)-1,"SIGN %s",tmp);
2397 if (sockfd) sendcommand(sockfd,sign,NULL);
2400 @@ -2197,13 +2197,13 @@ void start_spooldaemon(char *localhost) {
2402 sockfd=open_connection(localhost,SERVICE);
2404 - if (sockfd==-1) snprintf(MAXS(tmp),"cannot create a network socket "
2405 + if (sockfd==-1) snprintf(tmp,sizeof(tmp)-1,"cannot create a network socket "
2406 "- cannot start local spool daemon");
2407 - if (sockfd==-2) snprintf(MAXS(tmp),"cannot open connection to %s "
2408 + if (sockfd==-2) snprintf(tmp,sizeof(tmp)-1,"cannot open connection to %s "
2409 "- cannot start local spool daemon",localhost);
2410 - if (sockfd==-3) snprintf(MAXS(tmp),"%s is unknown (name server down?) "
2411 + if (sockfd==-3) snprintf(tmp,sizeof(tmp)-1,"%s is unknown (name server down?) "
2412 "- cannot start local spool daemon",localhost);
2413 - if (sockfd==-4) snprintf(MAXS(tmp),"out of memory "
2414 + if (sockfd==-4) snprintf(tmp,sizeof(tmp)-1,"out of memory "
2415 "- cannot start local spool daemon");
2418 @@ -2215,10 +2215,10 @@ void start_spooldaemon(char *localhost) {
2419 if (!str_beq(line,"220 ") || !strstr(line,"SAFT")) {
2421 #ifndef ENABLE_MULTIPROTOCOL
2422 - snprintf(MAXS(tmp),"No SAFT server on port %d at %s "
2423 + snprintf(tmp,sizeof(tmp)-1,"No SAFT server on port %d at %s "
2424 "- cannot start local spool daemon",SAFT,localhost);
2426 - snprintf(MAXS(tmp),"No SAFT server on port %s at %s "
2427 + snprintf(tmp,sizeof(tmp)-1,"No SAFT server on port %s at %s "
2428 "- cannot start local spool daemon",SERVICE,localhost);
2430 message(prg,'F',tmp);
2431 @@ -2241,13 +2241,13 @@ void start_spooldaemon(char *localhost) {
2433 sockfd=open_connection(host,SERVICE);
2435 - if (sockfd==-1) snprintf(MAXS(tmp),"cannot create a network socket "
2436 + if (sockfd==-1) snprintf(tmp,sizeof(tmp)-1,"cannot create a network socket "
2437 "- cannot start local spool daemon");
2438 - if (sockfd==-2) snprintf(MAXS(tmp),"cannot open connection to %s "
2439 + if (sockfd==-2) snprintf(tmp,sizeof(tmp)-1,"cannot open connection to %s "
2440 "- cannot start local spool daemon",host);
2441 - if (sockfd==-3) snprintf(MAXS(tmp),"%s is unknown (name server down?) "
2442 + if (sockfd==-3) snprintf(tmp,sizeof(tmp)-1,"%s is unknown (name server down?) "
2443 "- cannot start local spool daemon",host);
2444 - if (sockfd==-4) snprintf(MAXS(tmp),"out of memory "
2445 + if (sockfd==-4) snprintf(tmp,sizeof(tmp)-1,"out of memory "
2446 "- cannot start local spool daemon");
2449 @@ -2259,10 +2259,10 @@ void start_spooldaemon(char *localhost) {
2450 if (!str_beq(line,"220 ") || !strstr(line,"SAFT")) {
2452 #ifndef ENABLE_MULTIPROTOCOL
2453 - snprintf(MAXS(tmp),"No SAFT server on port %d at %s "
2454 + snprintf(tmp,sizeof(tmp)-1,"No SAFT server on port %d at %s "
2455 "- cannot start local spool daemon",SAFT,host);
2457 - snprintf(MAXS(tmp),"No SAFT server on port %s at %s "
2458 + snprintf(tmp,sizeof(tmp)-1,"No SAFT server on port %s at %s "
2459 "- cannot start local spool daemon",SERVICE,host);
2461 message(prg,'F',tmp);
2462 @@ -2392,7 +2392,7 @@ void get_header(const char *cmd, char *arg){
2463 if (!str_eq(cmd,line)) {
2466 - snprintf(MAXS(tmp),
2467 + snprintf(tmp,sizeof(tmp)-1,
2468 "illegal SAFT command \"%s\", \"%s\" was expected",line,cmd);
2469 message(prg,'F',tmp);
2471 @@ -2473,7 +2473,7 @@ char guess_ftype(const char *file, char *type) {
2472 /* next, try with file command */
2474 /* read output from file command */
2475 - snprintf(MAXS(cmd),"file %s",shell_quote(file));
2476 + snprintf(cmd,sizeof(cmd)-1,"file %s",shell_quote(file));
2477 if ((pipe=vpopen(cmd,"r")) && fgetl(tmp,pipe)) {
2480 @@ -2485,7 +2485,7 @@ char guess_ftype(const char *file, char *type) {
2481 if ((cp=strchr(type,'\n'))) *cp=0;
2484 - snprintf(MAXS(tmp),"%s is of type %s",file,type);
2485 + snprintf(tmp,sizeof(tmp)-1,"%s is of type %s",file,type);
2486 message(prg,'I',tmp);
2489 @@ -2535,14 +2535,14 @@ int linkspeed(const char *host, int lanspeed, char **compress) {
2490 if (lanspeed<1) return(1);
2492 /* create speeds dir if necessary */
2493 - snprintf(MAXS(speeddir),"%s/speeds",userspool);
2494 + snprintf(speeddir,sizeof(speeddir)-1,"%s/speeds",userspool);
2495 if (stat(speeddir,&finfo)<0 || !S_ISDIR(finfo.st_mode)) {
2497 if (mkdir(speeddir,S_IRUSR|S_IWUSR|S_IXUSR)<0) return(1);
2498 chmod(speeddir,S_IRUSR|S_IWUSR|S_IXUSR);
2501 - snprintf(MAXS(hostfile),"%s/%s",speeddir,host);
2502 + snprintf(hostfile,sizeof(hostfile)-1,"%s/%s",speeddir,host);
2504 /* if host file is missing return slow link */
2505 if (!(inf=rfopen(hostfile,"r"))) return(1);
2506 @@ -2552,11 +2552,11 @@ int linkspeed(const char *host, int lanspeed, char **compress) {
2507 if (speed<lanspeed) return(1);
2510 - snprintf(MAXS(msg),
2511 + snprintf(msg,sizeof(msg)-1,
2512 "disabling compressing because last link speed to %s was %d kB/s",
2514 message(prg,'I',msg);
2515 - snprintf(MAXS(msg),"LAN speed is defined as min %d kB/s",lanspeed);
2516 + snprintf(msg,sizeof(msg)-1,"LAN speed is defined as min %d kB/s",lanspeed);
2517 message(prg,'I',msg);
2520 @@ -2587,14 +2587,14 @@ void notespeed(const char *host, unsigned long size, float ttime) {
2521 if (ttime<1 || size<102400) return;
2523 /* create speeds dir if necessary */
2524 - snprintf(MAXS(speeddir),"%s/speeds",userspool);
2525 + snprintf(speeddir,sizeof(speeddir)-1,"%s/speeds",userspool);
2526 if (stat(speeddir,&finfo)<0 || !S_ISDIR(finfo.st_mode)) {
2528 if (mkdir(speeddir,S_IRUSR|S_IWUSR|S_IXUSR)<0) return;
2529 chmod(speeddir,S_IRUSR|S_IWUSR|S_IXUSR);
2532 - snprintf(MAXS(hostfile),"%s/%s",speeddir,host);
2533 + snprintf(hostfile,sizeof(hostfile)-1,"%s/%s",speeddir,host);
2535 if ((outf=rfopen(hostfile,"w"))) {
2536 fprintf(outf,"%d\n",(int)(size/ttime/1.024)); /* kB/s */
2537 @@ -2658,7 +2658,7 @@ void spooled_info(const char *file, const char *sdf, int compressed) {
2538 if (quiet>1) return;
2540 if (stat(sdf,&finfo)<0) {
2541 - snprintf(MAXS(tmp),"cannot access spool file %s",sdf);
2542 + snprintf(tmp,sizeof(tmp)-1,"cannot access spool file %s",sdf);
2543 message(prg,'E',tmp);
2546 @@ -2666,9 +2666,9 @@ void spooled_info(const char *file, const char *sdf, int compressed) {
2547 size=(finfo.st_size+512)/1024;
2550 - snprintf(MAXS(tmp),"'%s' spooled (%d KB [compressed])",file,size);
2551 + snprintf(tmp,sizeof(tmp)-1,"'%s' spooled (%d KB [compressed])",file,size);
2553 - snprintf(MAXS(tmp),"'%s' spooled (%d KB)",file,size);
2554 + snprintf(tmp,sizeof(tmp)-1,"'%s' spooled (%d KB)",file,size);
2555 message(prg,'I',tmp);
2558 diff --git a/src/sendfiled.c b/src/sendfiled.c
2559 index eb25612..39715e5 100644
2560 --- a/src/sendfiled.c
2561 +++ b/src/sendfiled.c
2562 @@ -655,7 +655,7 @@ int main(int argc, char *argv[]) {
2564 if (str_eq(line,"path")) {
2566 - snprintf(MAXS(path),"PATH=%s",argp);
2567 + snprintf(path,sizeof(path)-1,"PATH=%s",argp);
2571 @@ -665,7 +665,7 @@ int main(int argc, char *argv[]) {
2574 if (str_eq(line,"forcepgp")) {
2575 - snprintf(MAXS(sys_forcepgp),"%s",argp);
2576 + snprintf(sys_forcepgp,sizeof(sys_forcepgp)-1,"%s",argp);
2579 if (str_eq(line,"spooling")) {
2580 @@ -896,7 +896,7 @@ int main(int argc, char *argv[]) {
2581 strcpy(forcepgp,sys_forcepgp);
2583 /* parse the user config-file */
2584 - snprintf(MAXS(tmp),"%s/config",userconfig);
2585 + snprintf(tmp,sizeof(tmp)-1,"%s/config",userconfig);
2587 if ((inf=rfopen(tmp,"r"))) {
2588 while ((fgetl(line,inf))) {
2589 @@ -935,7 +935,7 @@ int main(int argc, char *argv[]) {
2591 /* pgp force option */
2592 if (str_eq(line,"forcepgp")) {
2593 - snprintf(MAXS(forcepgp),"%s",argp);
2594 + snprintf(forcepgp,sizeof(forcepgp)-1,"%s",argp);
2598 @@ -946,7 +946,7 @@ int main(int argc, char *argv[]) {
2599 if (str_beq(argp,"mail")) strcpy(notification,"m");
2600 if (str_eq(argp,"both")) strcpy(notification,"b");
2601 if (str_eq(argp,"program"))
2602 - snprintf(MAXS(notification),"%s/notify ",userconfig);
2603 + snprintf(notification,sizeof(notification)-1,"%s/notify ",userconfig);
2606 /* mail address specified to send notifications to? */
2607 @@ -1038,18 +1038,18 @@ int main(int argc, char *argv[]) {
2609 if (str_eq(peer,"localhost")) peer=localhost;
2610 if (strlen(arg)+strlen(peer)+strlen(real)+4<MAXLEN) {
2611 - snprintf(MAXS(utfsender),"%s@%s %s",arg,peer,real);
2612 - snprintf(MAXS(tmp),"%s@%s (%s)",arg,peer,real);
2613 + snprintf(utfsender,sizeof(utfsender)-1,"%s@%s %s",arg,peer,real);
2614 + snprintf(tmp,sizeof(tmp)-1,"%s@%s (%s)",arg,peer,real);
2615 utf2iso(0,sender,NULL,NULL,tmp);
2616 if ((cp=strchr(utfsender,' '))) {
2618 - snprintf(MAXS(logsender),"%s (%s)",utfsender,cp+1);
2619 + snprintf(logsender,sizeof(logsender)-1,"%s (%s)",utfsender,cp+1);
2622 strcpy(logsender,utfsender);
2624 - snprintf(MAXS(utfsender),"???@%s",peer);
2625 - snprintf(MAXS(sender),"???@%s",peer);
2626 + snprintf(utfsender,sizeof(utfsender)-1,"???@%s",peer);
2627 + snprintf(sender,sizeof(sender)-1,"???@%s",peer);
2631 @@ -1087,7 +1087,7 @@ int main(int argc, char *argv[]) {
2632 if ((cp=strchr(date,'T'))) *cp=' ';
2633 if (!strchr(date,'-')) {
2635 - snprintf(MAXS(date),"%c%c%c%c-%c%c-%c%c %c%c:%c%c:%c%c",
2636 + snprintf(date,sizeof(date)-1,"%c%c%c%c-%c%c-%c%c %c%c:%c%c:%c%c",
2637 tmp[0],tmp[1],tmp[2],tmp[3],
2640 @@ -1402,7 +1402,7 @@ int main(int argc, char *argv[]) {
2642 if (bell) strcat(msg,"\007");
2643 strftime(currentdate,9,"%H:%M",localtime(&timetick));
2644 - snprintf(MAXS(msgh),"Message from %s at %s :",sender,currentdate);
2645 + snprintf(msgh,sizeof(msgh)-1,"Message from %s at %s :",sender,currentdate);
2647 /* try to send to recipient ttys */
2648 if (msg2tty(recipient,msgh,msg,O_SYNC)<0)
2649 @@ -1412,7 +1412,7 @@ int main(int argc, char *argv[]) {
2650 /* log sender address */
2651 if (rgid) setegid(rgid);
2652 if (ruid) seteuid(ruid);
2653 - snprintf(MAXS(tmp),"%s/msg@%s",userconfig,localhost);
2654 + snprintf(tmp,sizeof(tmp)-1,"%s/msg@%s",userconfig,localhost);
2655 if ((outf=rfopen(tmp,"w"))) {
2657 if ((cp=strchr(tmp,' '))) *cp=0;
2658 @@ -1566,7 +1566,7 @@ int main(int argc, char *argv[]) {
2660 /* open spool data file for appending */
2662 - snprintf(MAXS(sdfile),"%d.d",id);
2663 + snprintf(sdfile,sizeof(sdfile)-1,"%d.d",id);
2664 sdfd=open(sdfile,O_WRONLY|O_APPEND|O_LARGEFILE,S_IRUSR|S_IWUSR);
2665 if (sdfd<0) notify_reply(¬ify,notification,sender,recipient,
2667 @@ -1608,8 +1608,8 @@ int main(int argc, char *argv[]) {
2668 notify_reply(¬ify,notification,sender,recipient,mailto,bell,413);
2670 /* open spool header and data files */
2671 - snprintf(MAXS(shfile),"%d.h",id);
2672 - snprintf(MAXS(sdfile),"%d.d",id);
2673 + snprintf(shfile,sizeof(shfile)-1,"%d.h",id);
2674 + snprintf(sdfile,sizeof(sdfile)-1,"%d.d",id);
2675 sdfd=open(sdfile,O_WRONLY|O_CREAT|O_LARGEFILE,S_IRUSR|S_IWUSR);
2676 shfd=open(shfile,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR);
2677 if (shfd<0 || sdfd<0) notify_reply(¬ify,notification,sender,
2678 @@ -1734,7 +1734,7 @@ int main(int argc, char *argv[]) {
2681 /* open post-processing pipe */
2682 - snprintf(MAXS(tmp),"cat %s/%s %s/%s | %s && rm -f %s/%s %s/%s",
2683 + snprintf(tmp,sizeof(tmp)-1,"cat %s/%s %s/%s | %s && rm -f %s/%s %s/%s",
2687 @@ -1817,7 +1817,7 @@ int main(int argc, char *argv[]) {
2688 (str_eq(date,flp->date) || !*date) &&
2689 flags==flp->flags) {
2690 /* with same sizes? */
2691 - snprintf(MAXS(tmp),"%lld %lld",flp->csize,flp->osize);
2692 + snprintf(tmp,sizeof(tmp)-1,"%lld %lld",flp->csize,flp->osize);
2693 if (str_eq(tmp,sizes)) {
2695 /* number of bytes already transmitted */
2696 @@ -1931,14 +1931,14 @@ int main(int argc, char *argv[]) {
2699 /* write challenge file */
2700 - snprintf(MAXS(chfile),"tmp_challenge_%d",(int)getpid());
2701 + snprintf(chfile,sizeof(chfile)-1,"tmp_challenge_%d",(int)getpid());
2702 outf=rfopen(chfile,"w");
2703 if (!outf) reply(410);
2704 fprintf(outf,"%d",challenge);
2707 /* write challenge signature file */
2708 - snprintf(MAXS(csfile),"tmp_challenge_%d.asc",(int)getpid());
2709 + snprintf(csfile,sizeof(csfile)-1,"tmp_challenge_%d.asc",(int)getpid());
2711 outf=rfopen(csfile,"w");
2713 @@ -1954,7 +1954,7 @@ int main(int argc, char *argv[]) {
2714 * pgp -sbaf +clearsig=on +secring=private.pgp +pubring=private.pgp
2717 - snprintf(MAXS(tmp),"%s +pubring=config/public.pgp %s %s 2>/dev/null",
2718 + snprintf(tmp,sizeof(tmp)-1,"%s +pubring=config/public.pgp %s %s 2>/dev/null",
2719 pgp_bin,csfile,chfile);
2722 @@ -2009,7 +2009,7 @@ int main(int argc, char *argv[]) {
2725 /* change to user config directory */
2726 - snprintf(MAXS(tmp),"%s/config",userspool);
2727 + snprintf(tmp,sizeof(tmp)-1,"%s/config",userspool);
2728 if (chdir(tmp)<0) reply(410);
2730 /* change effective uid and gid to recipient */
2731 @@ -2138,7 +2138,7 @@ int main(int argc, char *argv[]) {
2734 /* open header file */
2735 - snprintf(MAXS(shfile),"%d.h",id);
2736 + snprintf(shfile,sizeof(shfile)-1,"%d.h",id);
2737 if (!(inf=rfopen(shfile,"r"))) reply(550);
2739 /* read and transfer header file */
2740 @@ -2163,7 +2163,7 @@ int main(int argc, char *argv[]) {
2743 /* open spool data file */
2744 - snprintf(MAXS(sdfile),"%d.d",id);
2745 + snprintf(sdfile,sizeof(sdfile)-1,"%d.d",id);
2746 if (stat(sdfile,&finfo)<0 || (infd=open(sdfile,O_RDONLY|O_LARGEFILE))<0) reply(550);
2747 if (transmitted>finfo.st_size) {
2749 @@ -2434,7 +2434,7 @@ void writeheader(int fd, const char *attribute, const char *value) {
2750 int hsize; /* header string size */
2751 char header[2*MAXLEN]; /* header string */
2753 - snprintf(MAXS(header),"%s\t%s\n",attribute,value);
2754 + snprintf(header,sizeof(header)-1,"%s\t%s\n",attribute,value);
2755 hsize=strlen(header);
2756 if (write(fd,header,hsize)<hsize) reply(412);
2758 @@ -2537,7 +2537,7 @@ int msg2tty(const char *recipient, const char *msgh, char *msg, int mode) {
2759 /* change effective uid to recipient for security reasons */
2762 - snprintf(MAXS(msgcf),"%s/config/tty@%s",userspool,localhost);
2763 + snprintf(msgcf,sizeof(msgcf)-1,"%s/config/tty@%s",userspool,localhost);
2765 /* force writing to all ttys which are open? */
2766 if (*msg && str_beq(msg,"wall!")) {
2767 @@ -2546,9 +2546,9 @@ int msg2tty(const char *recipient, const char *msgh, char *msg, int mode) {
2771 - snprintf(MAXS(output),"\r\n%s\n\r%s\r\n",msgh,msg);
2772 + snprintf(output,sizeof(output)-1,"\r\n%s\n\r%s\r\n",msgh,msg);
2774 - snprintf(MAXS(output),"\r\n%s\n\r",msgh);
2775 + snprintf(output,sizeof(output)-1,"\r\n%s\n\r",msgh);
2777 /* is there a message control file? */
2778 if (!wall && success<=0 && (inf=rfopen(msgcf,"r"))) {
2779 @@ -2586,7 +2586,7 @@ int msg2tty(const char *recipient, const char *msgh, char *msg, int mode) {
2780 /* scan through utmp (currently logged in users) */
2781 while (read(utmpfd,(char *)&uinfo,sizeof(uinfo))>0) {
2783 -#if defined(NEXT) || defined(BSD) || defined(ULTRIX) || defined(SOLARIS1)
2784 +#if defined(NEXT) || defined(BSD) || defined(ULTRIX) || defined(SOLARIS1) || defined(__APPLE__)
2785 strncpy(user,uinfo.ut_name,8);
2786 if (str_eq(recipient,user)) {
2788 @@ -2598,7 +2598,7 @@ int msg2tty(const char *recipient, const char *msgh, char *msg, int mode) {
2789 if (uinfo.ut_type==USER_PROCESS && str_eq(recipient,user)) {
2792 - snprintf(MAXS(tty),"/dev/%s",uinfo.ut_line);
2793 + snprintf(tty,sizeof(tty)-1,"/dev/%s",uinfo.ut_line);
2795 /* is the tty writeable? */
2796 if (stat(tty,&finfo)==0 &&
2797 @@ -2664,7 +2664,7 @@ void mail2user(const char *recipient, const char *sender, const char *msg) {
2798 while ((cp=strchr(sender,'\''))) *cp=' ';
2800 /* open pipe to sendmail */
2801 - snprintf(MAXS(cmd),SENDMAIL" %s",recipient);
2802 + snprintf(cmd,sizeof(cmd)-1,SENDMAIL" %s",recipient);
2803 pout=popen(cmd,"w");
2805 /* fill out mail message */
2806 @@ -2730,7 +2730,7 @@ int restricted(const char *sender, const char *recipient, char type) {
2810 - snprintf(MAXS(killfile),"%s/config/restrictions",userspool);
2811 + snprintf(killfile,sizeof(killfile)-1,"%s/config/restrictions",userspool);
2814 /* open and check killfile */
2815 @@ -2786,9 +2786,9 @@ off_t free_space() {
2819 - snprintf(MAXS(spool),"%s/.",userspool);
2820 + snprintf(spool,sizeof(spool)-1,"%s/.",userspool);
2822 - snprintf(MAXS(spool),"%s/.",SPOOL);
2823 + snprintf(spool,sizeof(spool)-1,"%s/.",SPOOL);
2825 #if defined(IRIX) || defined(IRIX64)
2826 if (statfs(spool,&fsinfo,sizeof(struct statfs),0)==0)
2827 @@ -2838,7 +2838,7 @@ int get_sizes(char *string, off_t *size, off_t *osize) {
2829 /* get maximum file size for this process */
2831 - if (getrlimit(RLIMIT_FSIZE,&rl)==0) snprintf(MAXS(max),"%llu",rl.rlim_cur);
2832 + if (getrlimit(RLIMIT_FSIZE,&rl)==0) snprintf(max,sizeof(max)-1,"%llu",rl.rlim_cur);
2835 /* get compressed and original file size string */
2836 @@ -2883,10 +2883,10 @@ int send_msg(const char *msg, const char *to, const char *recipient) {
2840 - snprintf(MAXS(user),"%s",to);
2841 - snprintf(MAXS(host),"%s",cp+1);
2842 + snprintf(user,sizeof(user)-1,"%s",to);
2843 + snprintf(host,sizeof(host)-1,"%s",cp+1);
2845 - snprintf(MAXS(user),"%s",to);
2846 + snprintf(user,sizeof(user)-1,"%s",to);
2847 strcpy(host,localhost);
2850 @@ -2901,24 +2901,24 @@ int send_msg(const char *msg, const char *to, const char *recipient) {
2851 sock_getline(sockfd,line);
2852 if (!str_beq(line,"220 ") || !strstr(line,"SAFT")) return(-1);
2854 - snprintf(MAXS(tmp),"connected to %s",host);
2855 + snprintf(tmp,sizeof(tmp)-1,"connected to %s",host);
2858 - snprintf(MAXS(line),"FROM %s autogenerated+ACA-SAFT+ACA-message",recipient);
2859 - snprintf(MAXS(line),"FROM %s",recipient);
2860 + snprintf(line,sizeof(line)-1,"FROM %s autogenerated+ACA-SAFT+ACA-message",recipient);
2861 + snprintf(line,sizeof(line)-1,"FROM %s",recipient);
2862 sock_putline(sockfd,line);
2863 if (!str_beq(getreply(sockfd),"200 ")) {
2867 - snprintf(MAXS(line),"TO %s",user);
2868 + snprintf(line,sizeof(line)-1,"TO %s",user);
2869 sock_putline(sockfd,line);
2870 if (!str_beq(getreply(sockfd),"200 ")) {
2874 iso2utf(tmp,(char*)msg);
2875 - snprintf(MAXS(line),"MSG %s",tmp);
2876 + snprintf(line,sizeof(line)-1,"MSG %s",tmp);
2877 sock_putline(sockfd,line);
2878 if (!str_beq(getreply(sockfd),"200 ")) {
2880 @@ -2978,7 +2978,7 @@ int sfsd(int queue, int parallel, int bounce, int retry, float mtp) {
2881 /* test outgoing spool */
2882 if (chdir(OUTGOING)<0) {
2883 if (queue==1) message(prg,'F',OUTGOING);
2884 - snprintf(MAXS(tmp),OUTGOING" : %s",strerror(errno));
2885 + snprintf(tmp,sizeof(tmp)-1,OUTGOING" : %s",strerror(errno));
2889 @@ -3022,16 +3022,16 @@ int sfsd(int queue, int parallel, int bounce, int retry, float mtp) {
2892 if ((lockf=open(lockfn,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR))<0) {
2893 - snprintf(MAXS(tmp),"cannot open %s : %s",lockfn,strerror(errno));
2894 + snprintf(tmp,sizeof(tmp)-1,"cannot open %s : %s",lockfn,strerror(errno));
2898 if (wlock_file(lockf)<0) {
2899 - snprintf(MAXS(tmp),"cannot lock %s : %s",lockfn,strerror(errno));
2900 + snprintf(tmp,sizeof(tmp)-1,"cannot lock %s : %s",lockfn,strerror(errno));
2904 - snprintf(MAXS(tmp),"%d\n",(int)getpid());
2905 + snprintf(tmp,sizeof(tmp)-1,"%d\n",(int)getpid());
2906 write(lockf,tmp,strlen(tmp));
2908 /* disconnect from client */
2909 @@ -3079,7 +3079,7 @@ int sfsd(int queue, int parallel, int bounce, int retry, float mtp) {
2913 - snprintf(MAXS(tmp),"connected to %s",hlp->host);
2914 + snprintf(tmp,sizeof(tmp)-1,"connected to %s",hlp->host);
2915 if (queue==1) message(prg,'I',tmp);
2918 @@ -3126,7 +3126,7 @@ int sfsd(int queue, int parallel, int bounce, int retry, float mtp) {
2921 if (str_eq(hlp->host,ahost)) {
2922 - snprintf(MAXS(line),"TO %s",arecipient);
2923 + snprintf(line,sizeof(line)-1,"TO %s",arecipient);
2924 sock_putline(sockfd,line);
2925 rs=getreply(sockfd);
2926 if (!str_beq(rs,"200")) {
2927 @@ -3150,7 +3150,7 @@ int sfsd(int queue, int parallel, int bounce, int retry, float mtp) {
2931 - snprintf(MAXS(tmp),"connected to %s (forward redirection)",
2932 + snprintf(tmp,sizeof(tmp)-1,"connected to %s (forward redirection)",
2934 if (queue==1) message(prg,'I',tmp);
2936 @@ -3252,7 +3252,7 @@ int sfsd(int queue, int parallel, int bounce, int retry, float mtp) {
2937 while ((ssec=t0-time(0)+retry*60)>0) {
2939 signal(SIGCHLD,sigchld);
2940 - snprintf(MAXS(tmp),"sleep %d s",ssec);
2941 + snprintf(tmp,sizeof(tmp)-1,"sleep %d s",ssec);
2945 @@ -3291,17 +3291,17 @@ int send_spooldata(int sockfd, char *oshfn, char *from, char *to,
2948 utf2iso(0,isoname,NULL,NULL,fname);
2949 - snprintf(MAXS(tmp),"sending %s to %s",isoname,to);
2950 + snprintf(tmp,sizeof(tmp)-1,"sending %s to %s",isoname,to);
2951 message(prg,'I',tmp);
2954 - snprintf(MAXS(tmp),"sending %s to %s@%s",fname,to,host);
2955 + snprintf(tmp,sizeof(tmp)-1,"sending %s to %s@%s",fname,to,host);
2958 strcpy(osdfn,oshfn);
2959 osdfn[strlen(osdfn)-1]='d';
2960 if (stat(osdfn,&finfo)<0) {
2961 - snprintf(MAXS(tmp),"cannot access %s",osdfn);
2962 + snprintf(tmp,sizeof(tmp)-1,"cannot access %s",osdfn);
2966 @@ -3318,10 +3318,10 @@ int send_spooldata(int sockfd, char *oshfn, char *from, char *to,
2968 /* write status log */
2969 mkdir(SPOOL"/LOG",S_IRUSR|S_IWUSR|S_IXUSR);
2970 - snprintf(MAXS(tmp),SPOOL"/LOG/%s:%s",from,host);
2971 + snprintf(tmp,sizeof(tmp)-1,SPOOL"/LOG/%s:%s",from,host);
2972 if ((mailf=rfopen(tmp,"a"))) {
2973 chmod(tmp,S_IRUSR|S_IWUSR);
2974 - snprintf(MAXS(tmp),"'%s' to %s",fname,to);
2975 + snprintf(tmp,sizeof(tmp)-1,"'%s' to %s",fname,to);
2976 utf2iso(1,line,NULL,NULL,tmp);
2978 strftime(tmp,21,DATEFORMAT,localtime(&timetick));
2979 @@ -3375,14 +3375,14 @@ int saftserver_connect(char *host, char *error) {
2980 for (hopcount=1; hopcount<11; hopcount++) {
2982 /* tell where to send to */
2983 - snprintf(MAXS(tmp),"opening connection to %s:%d",host,port);
2984 + snprintf(tmp,sizeof(tmp)-1,"opening connection to %s:%d",host,port);
2987 /* initiate the connection to the server */
2988 sockfd=open_connection(host,port);
2989 if (sockfd==-3 && port==SAFT) {
2990 - snprintf(MAXS(server),"saft.%s",host);
2991 - snprintf(MAXS(tmp),"opening connection to %s:%d",server,SAFT);
2992 + snprintf(server,sizeof(server)-1,"saft.%s",host);
2993 + snprintf(tmp,sizeof(tmp)-1,"opening connection to %s:%d",server,SAFT);
2995 sockfd=open_connection(server,SAFT);
2997 @@ -3419,7 +3419,7 @@ int saftserver_connect(char *host, char *error) {
2998 status=check_forward(sockfd,tmp,host,error);
2999 if (status==-1) return(-1);
3001 - snprintf(MAXS(tmp),"forward points to %s",host);
3002 + snprintf(tmp,sizeof(tmp)-1,"forward points to %s",host);
3006 @@ -3427,7 +3427,7 @@ int saftserver_connect(char *host, char *error) {
3009 /* connection is successfull */
3010 - snprintf(MAXS(tmp),"connected to %s:%d",host,port);
3011 + snprintf(tmp,sizeof(tmp)-1,"connected to %s:%d",host,port);
3015 @@ -3477,14 +3477,14 @@ int saftserver_connect(char *host, char *error) {
3016 for (hopcount=1; hopcount<11; hopcount++) {
3018 /* tell where to send to */
3019 - snprintf(MAXS(tmp),"opening connection to %s:%s",host,service);
3020 + snprintf(tmp,sizeof(tmp)-1,"opening connection to %s:%s",host,service);
3023 /* initiate the connection to the server */
3024 sockfd=open_connection(host,service);
3025 if (sockfd==-3 && (strcasecmp(service, SERVICE) == 0 || strcmp(service, PORT_STRING) == 0)) {
3026 - snprintf(MAXS(server),"saft.%s",host);
3027 - snprintf(MAXS(tmp),"opening connection to %s:%s",server,SERVICE);
3028 + snprintf(server,sizeof(server)-1,"saft.%s",host);
3029 + snprintf(tmp,sizeof(tmp)-1,"opening connection to %s:%s",server,SERVICE);
3031 sockfd=open_connection(server,SERVICE);
3033 @@ -3523,7 +3523,7 @@ int saftserver_connect(char *host, char *error) {
3034 status=check_forward(sockfd,tmp,host,error);
3035 if (status==-1) return(-1);
3037 - snprintf(MAXS(tmp),"forward points to %s",host);
3038 + snprintf(tmp,sizeof(tmp)-1,"forward points to %s",host);
3042 @@ -3531,7 +3531,7 @@ int saftserver_connect(char *host, char *error) {
3045 /* connection is successfull */
3046 - snprintf(MAXS(tmp),"connected to %s:%s",host,service);
3047 + snprintf(tmp,sizeof(tmp)-1,"connected to %s:%s",host,service);
3051 @@ -3576,7 +3576,7 @@ int mail_report(const char *host) {
3052 /* stupid NeXT has a broken readdir(); this is a dirty workaround */
3055 - snprintf(MAXS(cmd),"ls *:%s 2>/dev/null",host);
3056 + snprintf(cmd,sizeof(cmd)-1,"ls *:%s 2>/dev/null",host);
3057 if ((dp=popen(cmd,"r")) == NULL) {
3059 if (parallel) continue;
3060 @@ -3597,7 +3597,7 @@ int mail_report(const char *host) {
3061 while ((dire=readdir(dp))) {
3063 strcpy(mailfn,dire->d_name);
3064 - snprintf(MAXS(tmp),"*:%s",host);
3065 + snprintf(tmp,sizeof(tmp)-1,"*:%s",host);
3066 if (simplematch(mailfn,tmp,0)<1) continue;
3068 mailf=rfopen(mailfn,"r");
3069 @@ -3693,7 +3693,7 @@ void check_outspool(int bounce) {
3070 while ((dire=readdir(dp))) {
3072 /* ignore non-header files */
3073 - snprintf(MAXS(oshfn),"%s",dire->d_name);
3074 + snprintf(oshfn,sizeof(oshfn)-1,"%s",dire->d_name);
3075 if (!str_eq(&oshfn[strlen(oshfn)-2],".h")) continue;
3078 @@ -3703,7 +3703,7 @@ void check_outspool(int bounce) {
3080 /* spool time expired? */
3081 if (timetick>finfo.st_mtime+bounce*DAYSEC) {
3082 - snprintf(MAXS(tmp),"no connection within %d days",bounce);
3083 + snprintf(tmp,sizeof(tmp)-1,"no connection within %d days",bounce);
3084 bounce_file(oshfn,tmp);
3087 @@ -3749,8 +3749,8 @@ int bounce_file(char *file, char *comment) {
3091 - snprintf(MAXS(oshfn),OUTGOING"/%s",cp);
3092 - snprintf(MAXS(osdfn),OUTGOING"/%s",cp);
3093 + snprintf(oshfn,sizeof(oshfn)-1,OUTGOING"/%s",cp);
3094 + snprintf(osdfn,sizeof(osdfn)-1,OUTGOING"/%s",cp);
3095 osdfn[strlen(osdfn)-1]='d';
3097 if (stat(oshfn,&finfo)<0) return(-1);
3098 @@ -3758,7 +3758,7 @@ int bounce_file(char *file, char *comment) {
3100 /* get user name and spool directory */
3101 if (!(pwe=getpwuid(finfo.st_uid))) return(-1);
3102 - snprintf(MAXS(userspool),SPOOL"/%s",pwe->pw_name);
3103 + snprintf(userspool,sizeof(userspool)-1,SPOOL"/%s",pwe->pw_name);
3105 /* create user spool directory if necessary */
3106 if (mkdir(userspool,S_IRUSR|S_IWUSR|S_IXUSR)==0)
3107 @@ -3788,8 +3788,8 @@ int bounce_file(char *file, char *comment) {
3110 /* set file names */
3111 - snprintf(MAXS(shfn),"%d.h",id);
3112 - snprintf(MAXS(sdfn),"%d.d",id);
3113 + snprintf(shfn,sizeof(shfn)-1,"%d.h",id);
3114 + snprintf(sdfn,sizeof(sdfn)-1,"%d.d",id);
3116 if (!(outf=rfopen(shfn,"w"))) {
3118 @@ -3814,7 +3814,7 @@ int bounce_file(char *file, char *comment) {
3120 /* add new bounce COMMENT */
3121 if (str_eq(hline,"TO")) {
3122 - snprintf(MAXS(tmp),"cannot sent to %s : %s",arg,comment);
3123 + snprintf(tmp,sizeof(tmp)-1,"cannot sent to %s : %s",arg,comment);
3125 fprintf(outf,"COMMENT\t%s\n",arg);
3127 @@ -3930,7 +3930,7 @@ int check_userspool(char *user, int userconfighome) {
3130 /* stupid NeXT has a broken getpwnam(); this is a dirty workaround */
3131 - snprintf(MAXS(tmp),"( nidump passwd . ; nidump passwd / ) | "
3132 + snprintf(tmp,sizeof(tmp)-1,"( nidump passwd . ; nidump passwd / ) | "
3133 "awk -F: '$1==\"%s\"{print $3,$4;exit}'",user);
3135 if (fgetl(tmp,pp) && *tmp!='\n' && *tmp!=0) {
3136 @@ -3958,8 +3958,8 @@ int check_userspool(char *user, int userconfighome) {
3138 /* build user spool string */
3140 - snprintf(MAXS(userspool),SPOOL"/%s",user);
3141 - snprintf(MAXS(userconfig),"%s/config",userspool);
3142 + snprintf(userspool,sizeof(userspool)-1,SPOOL"/%s",user);
3143 + snprintf(userconfig,sizeof(userconfig)-1,"%s/config",userspool);
3145 /* create user spool directory for user */
3146 if (mkdir(userspool,S_IRUSR|S_IWUSR|S_IXUSR)==0) chown(userspool,ruid,rgid);
3147 @@ -4173,14 +4173,16 @@ void cleanup() {
3148 * RETURN: nothing, but terminates program on error
3151 - if (rgid && setegid(rgid)<0) {
3152 - printf("490 Internal error on setegid(%u): %s\r\n",
3153 - (unsigned int)rgid,strerror(errno));
3154 + if (rgid && rgid != getegid() && setegid(rgid)<0) {
3155 + printf("490 Internal error on setegid(%u): %s [%u/%u]\r\n",
3156 + (unsigned int)rgid,strerror(errno),
3157 + geteuid(), getegid());
3160 - if (ruid && seteuid(ruid)<0) {
3161 - printf("490 Internal error on seteuid(%u): %s\r\n",
3162 - (unsigned int)ruid,strerror(errno));
3163 + if (ruid && ruid != geteuid() && seteuid(ruid)<0) {
3164 + printf("490 Internal error on seteuid(%u): %s [%u/%u]\r\n",
3165 + (unsigned int)ruid,strerror(errno),
3166 + geteuid(), getegid());
3170 @@ -4222,13 +4224,13 @@ int sudo(const char *user, const char *cmd) {
3171 if (setuid(pwe->pw_uid)<0) exit(1);
3173 /* set some usefull environment variables */
3174 - snprintf(MAXS(tmp),"HOME=%s",pwe->pw_dir);
3175 + snprintf(tmp,sizeof(tmp)-1,"HOME=%s",pwe->pw_dir);
3177 - snprintf(MAXS(tmp),"SHELL=%s",pwe->pw_shell);
3178 + snprintf(tmp,sizeof(tmp)-1,"SHELL=%s",pwe->pw_shell);
3180 - snprintf(MAXS(tmp),"USER=%s",user);
3181 + snprintf(tmp,sizeof(tmp)-1,"USER=%s",user);
3183 - snprintf(MAXS(tmp),"LOGNAME=%s",user);
3184 + snprintf(tmp,sizeof(tmp)-1,"LOGNAME=%s",user);
3188 diff --git a/src/sendmsg.c b/src/sendmsg.c
3189 index 23c60b1..2dd4318 100644
3192 @@ -260,10 +260,10 @@ int main(int argc, char *argv[]) {
3195 /* test if you can receive messages */
3196 - snprintf(MAXS(line),"FROM %s",login);
3197 + snprintf(line,sizeof(line)-1,"FROM %s",login);
3198 sock_putline(sockfd,line);
3199 sock_getline(sockfd,line);
3200 - snprintf(MAXS(line),"TO %s",login);
3201 + snprintf(line,sizeof(line)-1,"TO %s",login);
3202 sock_putline(sockfd,line);
3203 sock_getline(sockfd,line);
3204 if (str_beq(line,"521 ")) {
3205 @@ -281,7 +281,7 @@ int main(int argc, char *argv[]) {
3208 /* the message tty config file */
3209 - snprintf(MAXS(msgcf),"%s/%s/config/tty@%s",SPOOL,login,localhost);
3210 + snprintf(msgcf,sizeof(msgcf)-1,"%s/%s/config/tty@%s",SPOOL,login,localhost);
3212 /* open tty write permissions if necessary */
3214 @@ -293,14 +293,14 @@ int main(int argc, char *argv[]) {
3215 fprintf(outf,"%s\n",tty);
3217 if (chmod(tty,S_IRUSR|S_IWUSR|S_IWGRP)<0) {
3218 - snprintf(MAXS(tmp),"cannot open your tty %s for writing",tty);
3219 + snprintf(tmp,sizeof(tmp)-1,"cannot open your tty %s for writing",tty);
3220 message(prg,'W',tmp);
3221 } else if (argc-optind<1) {
3223 "receiving messages is now restricted to this tty");
3226 - snprintf(MAXS(tmp),"cannot configure your tty "
3227 + snprintf(tmp,sizeof(tmp)-1,"cannot configure your tty "
3228 "(no write access to %s)",msgcf);
3229 message(prg,'W',tmp);
3231 @@ -318,7 +318,7 @@ int main(int argc, char *argv[]) {
3232 /* is the current tty writable? */
3233 if (stat(tty,&finfo)<0 || !(finfo.st_mode&S_IWGRP)) {
3235 - snprintf(MAXS(tmp),"your tty %s is write protected; "
3236 + snprintf(tmp,sizeof(tmp)-1,"your tty %s is write protected; "
3237 "try sendmsg -m",tty);
3238 message(prg,'F',tmp);
3240 @@ -401,7 +401,7 @@ int main(int argc, char *argv[]) {
3243 /* send the message */
3244 - snprintf(MAXS(tmp),"MSG %s",utf_msg);
3245 + snprintf(tmp,sizeof(tmp)-1,"MSG %s",utf_msg);
3246 sendheader(sockfd,tmp);
3249 @@ -433,7 +433,7 @@ int main(int argc, char *argv[]) {
3250 iso2utf(utf_msg,iso_msg);
3252 /* send the message */
3253 - snprintf(MAXS(line),"MSG %s",utf_msg);
3254 + snprintf(line,sizeof(line)-1,"MSG %s",utf_msg);
3255 sock_putline(sockfd,line);
3257 sr=getreply(sockfd);
3258 @@ -441,12 +441,12 @@ int main(int argc, char *argv[]) {
3260 if (!(str_beq(sr,"200") || str_beq(sr,"202"))) {
3261 if (strstr(sr,"Timeout")) {
3262 - snprintf(MAXS(tmp),"server timeout");
3263 + snprintf(tmp,sizeof(tmp)-1,"server timeout");
3264 message(prg,'W',tmp);
3265 sockfd=saft_connect("msg",recipient,user,host,tmp);
3266 sendheader(sockfd,line);
3268 - snprintf(MAXS(tmp),"server error: %s",sr+4);
3269 + snprintf(tmp,sizeof(tmp)-1,"server error: %s",sr+4);
3270 message(prg,'X',tmp);
3273 diff --git a/src/spool.c b/src/spool.c
3274 index a1fdd8e..5f36085 100644
3277 @@ -181,7 +181,7 @@ struct senderlist *scanspool(char *sender) {
3278 /* mega stupid NeXT has broken readdir() */
3280 /* open spool dir */
3281 - snprintf(MAXS(tmp),"ls %s 2>/dev/null",userspool);
3282 + snprintf(tmp,sizeof(tmp)-1,"ls %s 2>/dev/null",userspool);
3283 if ((pp=popen(tmp,"r")) == NULL) return(NULL);
3285 /* scan through spool directory */
3286 @@ -216,7 +216,7 @@ struct senderlist *scanspool(char *sender) {
3289 /* open header file */
3290 - snprintf(MAXS(file),"%s/%d.h",userspool,id);
3291 + snprintf(file,sizeof(file)-1,"%s/%d.h",userspool,id);
3292 hf=rfopen(file,"r");
3295 @@ -224,7 +224,7 @@ struct senderlist *scanspool(char *sender) {
3297 /* called from receive client? */
3299 - snprintf(MAXS(msg),"cannot open spool file %s",file);
3300 + snprintf(msg,sizeof(msg)-1,"cannot open spool file %s",file);
3301 message("",'E',msg);
3304 @@ -246,9 +246,9 @@ struct senderlist *scanspool(char *sender) {
3307 /* does the spool data file exist? */
3308 - snprintf(MAXS(file),"%s/%d.d",userspool,id);
3309 + snprintf(file,sizeof(file)-1,"%s/%d.d",userspool,id);
3310 if (stat(file,&finfo)<0) {
3311 - snprintf(MAXS(file),"%s/%d.h",userspool,id);
3312 + snprintf(file,sizeof(file)-1,"%s/%d.h",userspool,id);
3316 @@ -260,7 +260,7 @@ struct senderlist *scanspool(char *sender) {
3317 if (keep>0 && (ctime-rtime)/DAYSEC>=keep) {
3320 - snprintf(MAXS(file),"%s/%d.h",userspool,id);
3321 + snprintf(file,sizeof(file)-1,"%s/%d.h",userspool,id);
3325 @@ -293,7 +293,7 @@ struct senderlist *scanspool(char *sender) {
3326 if (str_eq(hline,"FROM")) {
3327 if ((cp=strchr(arg,' '))) {
3329 - snprintf(MAXS(tmp),"%s (%s)",arg,cp+1);
3330 + snprintf(tmp,sizeof(tmp)-1,"%s (%s)",arg,cp+1);
3333 utf2iso(0,from,NULL,NULL,tmp);
3334 @@ -372,9 +372,9 @@ struct senderlist *scanspool(char *sender) {
3335 /* junk file expired? */
3336 if (*from==0 || *fname==0 ||
3337 (tsize!=csize && deljunk>0 && (ctime-rtime)/DAYSEC>=deljunk)) {
3338 - snprintf(MAXS(file),"%s/%d.d",userspool,id);
3339 + snprintf(file,sizeof(file)-1,"%s/%d.d",userspool,id);
3341 - snprintf(MAXS(file),"%s/%d.h",userspool,id);
3342 + snprintf(file,sizeof(file)-1,"%s/%d.h",userspool,id);
3346 @@ -539,7 +539,7 @@ struct hostlist *scanoutspool(char *sender) {
3347 /* mega stupid NeXT has broken readdir() */
3349 /* open spool dir */
3350 - snprintf(MAXS(tmp),"cd %s;ls %s_*.h 2>/dev/null",OUTGOING,sender);
3351 + snprintf(tmp,sizeof(tmp)-1,"cd %s;ls %s_*.h 2>/dev/null",OUTGOING,sender);
3352 if ((pp=popen(tmp,"r")) == NULL) return(NULL);
3354 /* scan through spool directory */
3355 @@ -561,18 +561,18 @@ struct hostlist *scanoutspool(char *sender) {
3358 /* look for header files */
3359 - snprintf(MAXS(tmp),"%s*.h",sender);
3360 + snprintf(tmp,sizeof(tmp)-1,"%s*.h",sender);
3361 if (simplematch(hfn,tmp,1)==0) continue;
3364 - snprintf(MAXS(hfn),OUTGOING"/%s",tmp);
3365 + snprintf(hfn,sizeof(hfn)-1,OUTGOING"/%s",tmp);
3367 /* open header file */
3368 if ((hf=rfopen(hfn,"r")) == NULL) {
3370 /* called from receive client? */
3372 - snprintf(MAXS(msg),"cannot open outgoing spool file %s",hfn);
3373 + snprintf(msg,sizeof(msg)-1,"cannot open outgoing spool file %s",hfn);
3374 message("",'E',msg);
3377 @@ -776,19 +776,19 @@ int delete_sf(struct filelist *flp, int verbose) {
3378 extern int client; /* flag to determine client or server */
3379 extern char userspool[]; /* user spool directory */
3381 - snprintf(MAXS(file),"%s/%d.d",userspool,flp->id);
3382 + snprintf(file,sizeof(file)-1,"%s/%d.d",userspool,flp->id);
3384 - snprintf(MAXS(file),"%s/%d.h",userspool,flp->id);
3385 + snprintf(file,sizeof(file)-1,"%s/%d.h",userspool,flp->id);
3386 utf2iso(1,NULL,fname,NULL,flp->fname);
3387 if(unlink(file)<0) {
3389 - snprintf(MAXS(msg),"cannot delete spoolfile #%d",flp->id);
3390 + snprintf(msg,sizeof(msg)-1,"cannot delete spoolfile #%d",flp->id);
3391 message("",'W',msg);
3396 - snprintf(MAXS(msg),"%s deleted",fname);
3397 + snprintf(msg,sizeof(msg)-1,"%s deleted",fname);
3398 message("",'I',msg);
3401 @@ -874,7 +874,7 @@ int spoolid(int maxfiles) {
3402 if (n>maxfiles) return(-n);
3404 /* try to create header spool file */
3405 - snprintf(MAXS(file),"%d.h",id);
3406 + snprintf(file,sizeof(file)-1,"%d.h",id);
3407 fd=open(file,O_CREAT|O_EXCL,S_IRUSR|S_IWUSR);
3410 @@ -883,7 +883,7 @@ int spoolid(int maxfiles) {
3413 /* create data spool file */
3414 - snprintf(MAXS(file),"%d.d",id);
3415 + snprintf(file,sizeof(file)-1,"%d.d",id);
3416 close(open(file,O_CREAT|O_LARGEFILE,S_IRUSR|S_IWUSR));