git://git.exim.org
/
users
/
jgh
/
exim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make useful socket functions more generally available
[users/jgh/exim.git]
/
src
/
src
/
demime.c
diff --git
a/src/src/demime.c
b/src/src/demime.c
index 961a2e046cf5b315ebae19f0697f968f239bac08..887678db3300df4bd3513b943ac04cbfaf0214e5 100644
(file)
--- a/
src/src/demime.c
+++ b/
src/src/demime.c
@@
-1,5
+1,3
@@
-/* $Cambridge: exim/src/src/demime.c,v 1.4 2005/02/17 11:58:26 ph10 Exp $ */
-
/*************************************************
* Exim - an Internet mail transport agent *
*************************************************/
/*************************************************
* Exim - an Internet mail transport agent *
*************************************************/
@@
-47,7
+45,7
@@
int demime(uschar **listptr) {
};
/* make sure the eml mbox file is spooled up */
};
/* make sure the eml mbox file is spooled up */
- mbox_file = spool_mbox(&mbox_size);
+ mbox_file = spool_mbox(&mbox_size
, NULL
);
if (mbox_file == NULL) {
/* error while spooling */
if (mbox_file == NULL) {
/* error while spooling */
@@
-60,7
+58,7
@@
int demime(uschar **listptr) {
if (!demime_ok)
demime_rc = mime_demux(mbox_file, defer_error_buffer);
if (!demime_ok)
demime_rc = mime_demux(mbox_file, defer_error_buffer);
- fclose(mbox_file);
+
(void)
fclose(mbox_file);
if (demime_rc == DEFER) {
/* temporary failure (DEFER => DEFER) */
if (demime_rc == DEFER) {
/* temporary failure (DEFER => DEFER) */
@@
-245,7
+243,7
@@
int mime_get_dump_file(uschar *extension, FILE **f, uschar *info) {
do {
struct stat mystat;
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 */
file_nr++;
if (file_nr >= MIME_SANITY_MAX_DUMP_FILES) {
/* max parts reached */
@@
-256,10
+254,10
@@
int mime_get_dump_file(uschar *extension, FILE **f, uschar *info) {
}
while(result != -1);
}
while(result != -1);
- *f =
fopen(CS file_name,"w+"
);
+ *f =
modefopen(file_name,"wb+",SPOOL_MODE
);
if (*f == NULL) {
/* cannot open new dump file, disk full ? -> soft error */
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;
};
return -2;
};
@@
-346,7
+344,7
@@
int mime_read_line(FILE *f, int mime_demux_mode, uschar *buffer, long *num_copie
c = fgetc(f);
if (c == EOF) break;
if ( (c == '\t') || (c == ' ') ) continue;
c = fgetc(f);
if (c == EOF) break;
if ( (c == '\t') || (c == ' ') ) continue;
- ungetc(c,f);
+
(void)
ungetc(c,f);
};
/* end of the header, terminate with ';' */
c = ';';
};
/* end of the header, terminate with ';' */
c = ';';
@@
-452,7
+450,7
@@
int mime_check_boundary(uschar *line, struct boundary *boundaries) {
for (i = 2; i < Ustrlen(line); i++) {
if ((line[i] != ' ') && (line[i] != '\t')) {
workbuf[j] = line[i];
for (i = 2; i < Ustrlen(line); i++) {
if ((line[i] != ' ') && (line[i] != '\t')) {
workbuf[j] = line[i];
-
j++;
+ j++;
};
};
workbuf[j+1]='\0';
};
};
workbuf[j+1]='\0';
@@
-533,13
+531,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) {
/* 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) {
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;
};
return -2;
};
@@
-656,7
+654,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) {
/* 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;
};
return -2;
};
@@
-820,10
+818,10
@@
void mime_trigger_error(int level, uschar *format, ...) {
sprintf(f,"demime acl condition: ");
f+=22;
va_start(ap, 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;
va_end(ap);
f-=22;
- log_write(0, LOG_MAIN, f);
+ log_write(0, LOG_MAIN,
"%s",
f);
/* then copy to demime_reason_buffer if new
level is greater than old level */
if (level > demime_errorlevel) {
/* then copy to demime_reason_buffer if new
level is greater than old level */
if (level > demime_errorlevel) {
@@
-866,7
+864,7
@@
int mime_demux(FILE *f, uschar *info) {
/* allocate room for our linebuffer */
line = (uschar *)malloc(MIME_SANITY_MAX_LINE_LENGTH);
if (line == NULL) {
/* 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;
};
return DEFER;
};
@@
-1078,14
+1076,14
@@
int mime_demux(FILE *f, uschar *info) {
if (data_len == -2) {
/* temp error, turn off uudecode mode */
if (uu_dump_file != NULL) {
if (data_len == -2) {
/* temp error, turn off uudecode mode */
if (uu_dump_file != NULL) {
- fclose(uu_dump_file); uu_dump_file = NULL;
+
(void)
fclose(uu_dump_file); uu_dump_file = NULL;
};
uu_mode = MIME_UU_MODE_OFF;
return DEFER;
}
else if (data_len == -1) {
if (uu_dump_file != NULL) {
};
uu_mode = MIME_UU_MODE_OFF;
return DEFER;
}
else if (data_len == -1) {
if (uu_dump_file != NULL) {
- fclose(uu_dump_file); uu_dump_file = NULL;
+
(void)
fclose(uu_dump_file); uu_dump_file = NULL;
};
uu_mode = MIME_UU_MODE_OFF;
data_len = 0;
};
uu_mode = MIME_UU_MODE_OFF;
data_len = 0;
@@
-1101,7
+1099,7
@@
int mime_demux(FILE *f, uschar *info) {
check for single "end" tag on line */
if ((strncmpic(line,US"end",3) == 0) && (line[3] < 32)) {
if (uu_dump_file != NULL) {
check for single "end" tag on line */
if ((strncmpic(line,US"end",3) == 0) && (line[3] < 32)) {
if (uu_dump_file != NULL) {
- fclose(uu_dump_file); uu_dump_file = NULL;
+
(void)
fclose(uu_dump_file); uu_dump_file = NULL;
};
uu_mode = MIME_UU_MODE_OFF;
}
};
uu_mode = MIME_UU_MODE_OFF;
}
@@
-1110,7
+1108,7
@@
int mime_demux(FILE *f, uschar *info) {
if (data_len == -2) {
/* temp error, turn off uudecode mode */
if (uu_dump_file != NULL) {
if (data_len == -2) {
/* temp error, turn off uudecode mode */
if (uu_dump_file != NULL) {
- fclose(uu_dump_file); uu_dump_file = NULL;
+
(void)
fclose(uu_dump_file); uu_dump_file = NULL;
};
uu_mode = MIME_UU_MODE_OFF;
return DEFER;
};
uu_mode = MIME_UU_MODE_OFF;
return DEFER;
@@
-1126,7
+1124,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 */
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;
};
free(line);
return DEFER;
};
@@
-1152,7
+1150,7
@@
int mime_demux(FILE *f, uschar *info) {
mime_demux(mime_dump_file,info);
};
mime_demux(mime_dump_file,info);
};
- fclose(mime_dump_file); mime_dump_file = NULL;
+
(void)
fclose(mime_dump_file); mime_dump_file = NULL;
};
}
else if (tmp == 2) {
};
}
else if (tmp == 2) {
@@
-1167,7
+1165,7
@@
int mime_demux(FILE *f, uschar *info) {
mime_demux(mime_dump_file,info);
};
mime_demux(mime_dump_file,info);
};
- fclose(mime_dump_file); mime_dump_file = NULL;
+
(void)
fclose(mime_dump_file); mime_dump_file = NULL;
};
}
else {
};
}
else {
@@
-1192,7
+1190,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 */
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;
};
free(line);
return DEFER;
};
@@
-1218,9
+1216,9
@@
int mime_demux(FILE *f, uschar *info) {
/* close files, they could still be open */
if (mime_dump_file != NULL)
/* close files, they could still be open */
if (mime_dump_file != NULL)
- fclose(mime_dump_file);
+
(void)
fclose(mime_dump_file);
if (uu_dump_file != NULL)
if (uu_dump_file != NULL)
- fclose(uu_dump_file);
+
(void)
fclose(uu_dump_file);
/* release line buffer */
free(line);
/* release line buffer */
free(line);
@@
-1234,7
+1232,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 */
/* 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); */
};
/* Removed FTTB. We need to decide on TNEF inclusion */
/* mime_unpack_tnef(file_name); */
};