diff options
author | Philip Hazel <ph10@hermes.cam.ac.uk> | 2005-08-01 14:41:25 +0000 |
---|---|---|
committer | Philip Hazel <ph10@hermes.cam.ac.uk> | 2005-08-01 14:41:25 +0000 |
commit | b07e6aa3aa6749ab57c214efd155bb29614394eb (patch) | |
tree | 8869df5874704a955873e8b63eb095404ceddc24 | |
parent | 1ab52c6910907a13b2f1895f53f43d0255a39d35 (diff) |
Convert all Tom's calls to snprintf() to string_format().
-rw-r--r-- | doc/doc-txt/ChangeLog | 6 | ||||
-rw-r--r-- | src/src/demime.c | 22 | ||||
-rw-r--r-- | src/src/dk.c | 4 | ||||
-rw-r--r-- | src/src/malware.c | 28 | ||||
-rw-r--r-- | src/src/mime.c | 10 | ||||
-rw-r--r-- | src/src/receive.c | 7 | ||||
-rw-r--r-- | src/src/spam.c | 8 | ||||
-rw-r--r-- | src/src/spool_mbox.c | 12 | ||||
-rw-r--r-- | src/src/transport.c | 4 |
9 files changed, 53 insertions, 48 deletions
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 5f37fd9c3..d2600f969 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.186 2005/08/01 14:00:34 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.187 2005/08/01 14:41:25 ph10 Exp $ Change log file for Exim from version 4.21 ------------------------------------------- @@ -21,6 +21,10 @@ PH/04 Added $message_exim_id, ultimately to replace $message_id (they will both co-exist for some time) to make it clear that it is the Exim ID that is referenced, not the Message-ID: header line. +PH/05 Replaced all Tom's calls to snprintf() with calls to the internal + string_format() function, because snprintf() does not exist on all + operating systems. + Exim version 4.52 ----------------- diff --git a/src/src/demime.c b/src/src/demime.c index 1f86407f8..0ab787741 100644 --- a/src/src/demime.c +++ b/src/src/demime.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/demime.c,v 1.7 2005/07/01 10:49:02 ph10 Exp $ */ +/* $Cambridge: exim/src/src/demime.c,v 1.8 2005/08/01 14:41:25 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -245,7 +245,7 @@ int mime_get_dump_file(uschar *extension, FILE **f, uschar *info) { do { struct stat mystat; - snprintf(CS file_name,1024,"%s/scan/%s/%s-%05u%s",spool_directory,message_id,message_id,file_nr,extension); + (void)string_format(file_name,1024,"%s/scan/%s/%s-%05u%s",spool_directory,message_id,message_id,file_nr,extension); file_nr++; if (file_nr >= MIME_SANITY_MAX_DUMP_FILES) { /* max parts reached */ @@ -259,7 +259,7 @@ int mime_get_dump_file(uschar *extension, FILE **f, uschar *info) { *f = fopen(CS file_name,"wb+"); if (*f == NULL) { /* cannot open new dump file, disk full ? -> soft error */ - snprintf(CS info, 1024,"unable to open dump file"); + (void)string_format(info, 1024,"unable to open dump file"); return -2; }; @@ -533,13 +533,13 @@ long uu_decode_line(uschar *line, uschar **data, long line_len, uschar *info) { /* allocate memory for data and work buffer */ *data = (uschar *)malloc(line_len); if (*data == NULL) { - snprintf(CS info, 1024,"unable to allocate %lu bytes",line_len); + (void)string_format(info, 1024,"unable to allocate %lu bytes",line_len); return -2; }; work = (uschar *)malloc(line_len); if (work == NULL) { - snprintf(CS info, 1024,"unable to allocate %lu bytes",line_len); + (void)string_format(info, 1024,"unable to allocate %lu bytes",line_len); return -2; }; @@ -656,7 +656,7 @@ long mime_decode_line(int mime_demux_mode,uschar *line, uschar **data, long max_ /* allocate memory for data */ *data = (uschar *)malloc(max_data_len); if (*data == NULL) { - snprintf(CS info, 1024,"unable to allocate %lu bytes",max_data_len); + (void)string_format(info, 1024,"unable to allocate %lu bytes",max_data_len); return -2; }; @@ -820,7 +820,7 @@ void mime_trigger_error(int level, uschar *format, ...) { sprintf(f,"demime acl condition: "); f+=22; va_start(ap, format); - vsnprintf(f, 16383,(char *)format, ap); + (void)string_vformat(US f, 16383,(char *)format, ap); va_end(ap); f-=22; log_write(0, LOG_MAIN, f); @@ -866,7 +866,7 @@ int mime_demux(FILE *f, uschar *info) { /* allocate room for our linebuffer */ line = (uschar *)malloc(MIME_SANITY_MAX_LINE_LENGTH); if (line == NULL) { - snprintf(CS info, 1024,"unable to allocate %u bytes",MIME_SANITY_MAX_LINE_LENGTH); + (void)string_format(info, 1024,"unable to allocate %u bytes",MIME_SANITY_MAX_LINE_LENGTH); return DEFER; }; @@ -1126,7 +1126,7 @@ int mime_demux(FILE *f, uschar *info) { if (data_len > 0) { if (fwrite(data,1,data_len,uu_dump_file) < data_len) { /* short write */ - snprintf(CS info, 1024,"short write on uudecode dump file"); + (void)string_format(info, 1024,"short write on uudecode dump file"); free(line); return DEFER; }; @@ -1192,7 +1192,7 @@ int mime_demux(FILE *f, uschar *info) { if (data_len > 0) { if (fwrite(data,1,data_len,mime_dump_file) < data_len) { /* short write */ - snprintf(CS info, 1024,"short write on dump file"); + (void)string_format(info, 1024,"short write on dump file"); free(line); return DEFER; }; @@ -1234,7 +1234,7 @@ int mime_demux(FILE *f, uschar *info) { /* at least one file could be TNEF encoded. attempt to send all decoded files thru the TNEF decoder */ - snprintf(CS file_name,1024,"%s/scan/%s",spool_directory,message_id); + (void)string_format(file_name,1024,"%s/scan/%s",spool_directory,message_id); /* Removed FTTB. We need to decide on TNEF inclusion */ /* mime_unpack_tnef(file_name); */ }; diff --git a/src/src/dk.c b/src/src/dk.c index 4d963f1a8..0a61e0f0b 100644 --- a/src/src/dk.c +++ b/src/src/dk.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/dk.c,v 1.6 2005/06/27 15:11:59 tom Exp $ */ +/* $Cambridge: exim/src/src/dk.c,v 1.7 2005/08/01 14:41:25 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -409,7 +409,7 @@ uschar *dk_exim_sign(int dk_fd, rc = store_get(1024); /* Build DomainKey-Signature header to return. */ - snprintf(CS rc, 1024, "DomainKey-Signature: a=rsa-sha1; q=dns; c=%s;\r\n" + (void)string_format(rc, 1024, "DomainKey-Signature: a=rsa-sha1; q=dns; c=%s;\r\n" "\ts=%s; d=%s;\r\n" "\tb=%s;\r\n", dk_canon, dk_selector, dk_domain, sig); diff --git a/src/src/malware.c b/src/src/malware.c index a790b284b..ca9c3dfeb 100644 --- a/src/src/malware.c +++ b/src/src/malware.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/malware.c,v 1.11 2005/07/01 10:49:02 ph10 Exp $ */ +/* $Cambridge: exim/src/src/malware.c,v 1.12 2005/08/01 14:41:25 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -199,7 +199,7 @@ int malware(uschar **listptr) { /* prepare variables */ drweb_cmd = htonl(DRWEBD_SCAN_CMD); drweb_flags = htonl(DRWEBD_RETURN_VIRUSES | DRWEBD_IS_MAIL); - snprintf(CS scanrequest, 1024,CS"%s/scan/%s/%s.eml", + (void)string_format(scanrequest, 1024,CS"%s/scan/%s/%s.eml", spool_directory, message_id, message_id); /* calc file size */ @@ -287,7 +287,7 @@ int malware(uschar **listptr) { /* prepare variables */ drweb_cmd = htonl(DRWEBD_SCAN_CMD); drweb_flags = htonl(DRWEBD_RETURN_VIRUSES | DRWEBD_IS_MAIL); - snprintf(CS scanrequest, 1024,CS"%s/scan/%s/%s.eml", spool_directory, message_id, message_id); + (void)string_format(scanrequest, 1024,CS"%s/scan/%s/%s.eml", spool_directory, message_id, message_id); drweb_slen = htonl(Ustrlen(scanrequest)); /* send scan request */ @@ -446,7 +446,7 @@ int malware(uschar **listptr) { }; /* prepare our command */ - snprintf(CS buf, 32768, "SCAN bPQRSTUW %s/scan/%s/%s.eml\r\n", spool_directory, message_id, message_id); + (void)string_format(buf, 32768, "SCAN bPQRSTUW %s/scan/%s/%s.eml\r\n", spool_directory, message_id, message_id); /* and send it */ if (send(sock, buf, Ustrlen(buf), 0) < 0) { @@ -479,7 +479,7 @@ int malware(uschar **listptr) { } /* prepare our command */ - snprintf(CS buf, 32768, "quit\r\n"); + (void)string_format(buf, 32768, "quit\r\n"); /* and send it */ if (send(sock, buf, Ustrlen(buf), 0) < 0) { @@ -571,7 +571,7 @@ int malware(uschar **listptr) { }; /* pass the mailfile to fsecure */ - snprintf(CS file_name,1024,"SCAN\t%s/scan/%s/%s.eml\n", spool_directory, message_id, message_id); + (void)string_format(file_name,1024,"SCAN\t%s/scan/%s/%s.eml\n", spool_directory, message_id, message_id); /* debug_printf("send scan %s",file_name); */ if (write(sock, file_name, Ustrlen(file_name)) < 0) { (void)close(sock); @@ -661,7 +661,7 @@ int malware(uschar **listptr) { /* get current date and time, build scan request */ time(&t); strftime(CS tmpbuf, sizeof(tmpbuf), "<0>%d %b %H:%M:%S:%%s/scan/%%s", localtime(&t)); - snprintf(CS scanrequest, 1024,CS tmpbuf, spool_directory, message_id); + (void)string_format(scanrequest, 1024,CS tmpbuf, spool_directory, message_id); /* send scan request */ if (send(sock, scanrequest, Ustrlen(scanrequest)+1, 0) < 0) { @@ -854,8 +854,8 @@ int malware(uschar **listptr) { }; /* prepare scanner call */ - snprintf(CS file_name,1024,"%s/scan/%s", spool_directory, message_id); - snprintf(CS commandline,1024, CS cmdline_scanner,file_name); + (void)string_format(file_name,1024,"%s/scan/%s", spool_directory, message_id); + (void)string_format(commandline,1024, CS cmdline_scanner,file_name); /* redirect STDERR too */ Ustrcat(commandline," 2>&1"); @@ -872,7 +872,7 @@ int malware(uschar **listptr) { return DEFER; }; - snprintf(CS file_name,1024,"%s/scan/%s/%s_scanner_output", spool_directory, message_id, message_id); + (void)string_format(file_name,1024,"%s/scan/%s/%s_scanner_output", spool_directory, message_id, message_id); scanner_record = fopen(CS file_name,"wb"); if (scanner_record == NULL) { @@ -964,7 +964,7 @@ int malware(uschar **listptr) { } /* pass the scan directory to sophie */ - snprintf(CS file_name,1024,"%s/scan/%s", spool_directory, message_id); + (void)string_format(file_name,1024,"%s/scan/%s", spool_directory, message_id); if (write(sock, file_name, Ustrlen(file_name)) < 0) { (void)close(sock); log_write(0, LOG_MAIN|LOG_PANIC, @@ -1079,7 +1079,7 @@ int malware(uschar **listptr) { /* Pass the string to ClamAV (7 = "SCAN \n" + \0) */ - snprintf(CS file_name,1024,"SCAN %s/scan/%s\n", spool_directory, message_id); + (void)string_format(file_name,1024,"SCAN %s/scan/%s\n", spool_directory, message_id); if (send(sock, file_name, Ustrlen(file_name), 0) < 0) { (void)close(sock); @@ -1141,7 +1141,7 @@ int malware(uschar **listptr) { return DEFER; } - snprintf(CS scanrequest, 1024,CS"%s/scan/%s/%s.eml", + (void)string_format(scanrequest, 1024,CS"%s/scan/%s/%s.eml", spool_directory, message_id, message_id); /* calc file size */ @@ -1218,7 +1218,7 @@ int malware(uschar **listptr) { /* Pass the string to ClamAV (7 = "SCAN \n" + \0) */ - snprintf(CS file_name,1024,"SCAN %s/scan/%s\n", spool_directory, message_id); + (void)string_format(file_name,1024,"SCAN %s/scan/%s\n", spool_directory, message_id); if (send(sock, file_name, Ustrlen(file_name), 0) < 0) { (void)close(sock); diff --git a/src/src/mime.c b/src/src/mime.c index a4ad0f509..548a16de7 100644 --- a/src/src/mime.c +++ b/src/src/mime.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/mime.c,v 1.9 2005/07/01 10:49:02 ph10 Exp $ */ +/* $Cambridge: exim/src/src/mime.c,v 1.10 2005/08/01 14:41:25 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -243,7 +243,7 @@ FILE *mime_get_decode_file(uschar *pname, uschar *fname) { filename = (uschar *)malloc(2048); if ((pname != NULL) && (fname != NULL)) { - snprintf(CS filename, 2048, "%s/%s", pname, fname); + (void)string_format(filename, 2048, "%s/%s", pname, fname); f = fopen(CS filename,"wb+"); } else if (pname == NULL) { @@ -256,7 +256,7 @@ FILE *mime_get_decode_file(uschar *pname, uschar *fname) { /* must find first free sequential filename */ do { struct stat mystat; - snprintf(CS filename,2048,"%s/%s-%05u", pname, message_id, file_nr); + (void)string_format(filename,2048,"%s/%s-%05u", pname, message_id, file_nr); file_nr++; /* security break */ if (file_nr >= 1024) @@ -292,7 +292,7 @@ int mime_decode(uschar **listptr) { f_pos = ftell(mime_stream); /* build default decode path (will exist since MBOX must be spooled up) */ - snprintf(CS decode_path,1024,"%s/scan/%s",spool_directory,message_id); + (void)string_format(decode_path,1024,"%s/scan/%s",spool_directory,message_id); /* reserve a line and decoder buffer to work in */ buffer = (uschar *)malloc(MIME_MAX_LINE_LENGTH+1); @@ -693,7 +693,7 @@ int mime_acl_check(uschar *acl, FILE *f, struct mime_boundary_context *context, /* must find first free sequential filename */ do { struct stat mystat; - snprintf(CS filename,2048,"%s/scan/%s/__rfc822_%05u", spool_directory, message_id, file_nr); + (void)string_format(filename,2048,"%s/scan/%s/__rfc822_%05u", spool_directory, message_id, file_nr); file_nr++; /* security break */ if (file_nr >= 128) diff --git a/src/src/receive.c b/src/src/receive.c index 7fa35878b..e2d6a1a1d 100644 --- a/src/src/receive.c +++ b/src/src/receive.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/receive.c,v 1.21 2005/07/01 10:49:02 ph10 Exp $ */ +/* $Cambridge: exim/src/src/receive.c,v 1.22 2005/08/01 14:41:25 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -1097,7 +1097,8 @@ if (rc == OK) { struct dirent *entry; DIR *tempdir; - snprintf(CS temp_path, 1024, "%s/scan/%s", spool_directory, message_id); + (void)string_format(temp_path, 1024, "%s/scan/%s", spool_directory, + message_id); tempdir = opendir(CS temp_path); n = 0; @@ -1105,7 +1106,7 @@ if (rc == OK) { entry = readdir(tempdir); if (entry == NULL) break; if (strncmpic(US entry->d_name,US"__rfc822_",9) == 0) { - snprintf(CS rfc822_file_path, 2048,"%s/scan/%s/%s", spool_directory, message_id, entry->d_name); + (void)string_format(rfc822_file_path, 2048,"%s/scan/%s/%s", spool_directory, message_id, entry->d_name); debug_printf("RFC822 attachment detected: running MIME ACL for '%s'\n", rfc822_file_path); break; }; diff --git a/src/src/spam.c b/src/src/spam.c index 7ee42680f..e49bc56bc 100644 --- a/src/src/spam.c +++ b/src/src/spam.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/spam.c,v 1.10 2005/06/27 15:11:04 tom Exp $ */ +/* $Cambridge: exim/src/src/spam.c,v 1.11 2005/08/01 14:41:25 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -195,7 +195,7 @@ int spam(uschar **listptr) { } /* now we are connected to spamd on spamd_sock */ - snprintf(CS spamd_buffer, + (void)string_format(spamd_buffer, sizeof(spamd_buffer), "REPORT SPAMC/1.2\r\nUser: %s\r\nContent-length: %ld\r\n\r\n", user_name, @@ -362,12 +362,12 @@ again: spam_bar = spam_bar_buffer; /* create "float" spam score */ - snprintf(CS spam_score_buffer, sizeof(spam_score_buffer),"%.1f", spamd_score); + (void)string_format(spam_score_buffer, sizeof(spam_score_buffer),"%.1f", spamd_score); spam_score = spam_score_buffer; /* create "int" spam score */ j = (int)((spamd_score + 0.001)*10); - snprintf(CS spam_score_int_buffer, sizeof(spam_score_int_buffer), "%d", j); + (void)string_format(spam_score_int_buffer, sizeof(spam_score_int_buffer), "%d", j); spam_score_int = spam_score_int_buffer; /* compare threshold against score */ diff --git a/src/src/spool_mbox.c b/src/src/spool_mbox.c index af9a46b84..e96dca48f 100644 --- a/src/src/spool_mbox.c +++ b/src/src/spool_mbox.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/spool_mbox.c,v 1.9 2005/08/01 13:51:05 ph10 Exp $ */ +/* $Cambridge: exim/src/src/spool_mbox.c,v 1.10 2005/08/01 14:41:25 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -48,14 +48,14 @@ FILE *spool_mbox(unsigned long *mbox_file_size) { }; /* create temp directory inside scan dir */ - snprintf(CS mbox_path, 1024, "%s/scan/%s", spool_directory, message_id); + (void)string_format(mbox_path, 1024, "%s/scan/%s", spool_directory, message_id); if (!directory_make(NULL, mbox_path, 0750, FALSE)) { debug_printf("unable to create directory: %s/scan/%s\n", spool_directory, message_id); return NULL; }; /* open [message_id].eml file for writing */ - snprintf(CS mbox_path, 1024, "%s/scan/%s/%s.eml", spool_directory, message_id, message_id); + (void)string_format(mbox_path, 1024, "%s/scan/%s/%s.eml", spool_directory, message_id, message_id); mbox_file = Ufopen(mbox_path,"wb"); if (mbox_file == NULL) { @@ -167,7 +167,7 @@ FILE *spool_mbox(unsigned long *mbox_file_size) { spool_mbox_ok = 1; }; - snprintf(CS mbox_path, 1024, "%s/scan/%s/%s.eml", spool_directory, message_id, message_id); + (void)string_format(mbox_path, 1024, "%s/scan/%s/%s.eml", spool_directory, message_id, message_id); /* get the size of the mbox message */ stat(CS mbox_path, &statbuf); @@ -204,7 +204,7 @@ void unspool_mbox(void) { struct dirent *entry; DIR *tempdir; - snprintf(CS mbox_path, 1024, "%s/scan/%s", spool_directory, spooled_message_id); + (void)string_format(mbox_path, 1024, "%s/scan/%s", spool_directory, spooled_message_id); tempdir = opendir(CS mbox_path); /* loop thru dir & delete entries */ @@ -212,7 +212,7 @@ void unspool_mbox(void) { do { entry = readdir(tempdir); if (entry == NULL) break; - snprintf(CS file_path, 1024,"%s/scan/%s/%s", spool_directory, spooled_message_id, entry->d_name); + (void)string_format(file_path, 1024,"%s/scan/%s/%s", spool_directory, spooled_message_id, entry->d_name); if ( (Ustrcmp(entry->d_name,"..") != 0) && (Ustrcmp(entry->d_name,".") != 0) ) { debug_printf("unspool_mbox(): unlinking '%s'\n", file_path); n = unlink(CS file_path); diff --git a/src/src/transport.c b/src/src/transport.c index a75a2dfa0..e66e498be 100644 --- a/src/src/transport.c +++ b/src/src/transport.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/transport.c,v 1.12 2005/06/27 14:29:44 ph10 Exp $ */ +/* $Cambridge: exim/src/src/transport.c,v 1.13 2005/08/01 14:41:25 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -984,7 +984,7 @@ dk_transport_write_message(address_item *addr, int fd, int options, int wwritten = 0; uschar *dk_signature = NULL; - snprintf(CS dk_spool_name, 256, "%s/input/%s/%s-K", + (void)string_format(dk_spool_name, 256, "%s/input/%s/%s-K", spool_directory, message_subdir, message_id); dk_fd = Uopen(dk_spool_name, O_RDWR|O_CREAT|O_EXCL, SPOOL_MODE); if (dk_fd < 0) |