1- diff -ur a/MIME_headers.c b/MIME_headers.c
2- --- a/MIME_headers.c 2023-09-27 11:05:54.988276818 +0000
3- +++ b/MIME_headers.c 2023-09-27 11:06:26.996936153 +0000
4- @@ -785,7 +785,7 @@
1+ From 4f89cd2aa95a553f1a84c00f0a83c98fc7867ae3 Mon Sep 17 00:00:00 2001
2+ From: Paul L Daniels <pldaniels@gmail.com>
3+ Date: Wed, 24 May 2023 22:11:46 +1000
4+ Subject: [PATCH] Modernisation of code; fixed up various compile issues.
5+
6+ ---
7+ MIME_headers.c | 10 +++++-----
8+ altermime.c | 2 +-
9+ mime_alter.c | 15 ++++++++-------
10+ mime_alter.h | 6 ++++--
11+ pldstr.c | 2 +-
12+ qpe.c | 2 +-
13+ 6 files changed, 20 insertions(+), 17 deletions(-)
14+
15+ diff --git a/MIME_headers.c b/MIME_headers.c
16+ index db294d9..d2b9c77 100644
17+ --- a/MIME_headers.c
18+ +++ b/MIME_headers.c
19+ @@ -785,7 +785,7 @@ int MIMEH_save_doubleCR( FFGET_FILE *f )
520
621 do {
722 glb.doubleCR_count++;
@@ -10,7 +25,7 @@ diff -ur a/MIME_headers.c b/MIME_headers.c
1025 }
1126 while (stat(glb.doubleCRname, &st) == 0);
1227
13- @@ -2012,7 +2012,7 @@
28+ @@ -2012,7 +2012,7 @@ int MIMEH_parse_contenttype( char *header_name, char *header_value, struct MIMEH
1429 {
1530 if (strlen(glb.appledouble_filename)>0)
1631 {
@@ -19,7 +34,7 @@ diff -ur a/MIME_headers.c b/MIME_headers.c
1934 } else {
2035 snprintf(hinfo->filename, sizeof(hinfo->filename), "applefile");
2136 }
22- @@ -2921,8 +2921,8 @@
37+ @@ -2921,8 +2921,8 @@ int MIMEH_headers_process( struct MIMEH_header_info *hinfo, char *headers )
2338 // Final analysis on our headers:
2439 if ( hinfo->content_type == _CTYPE_MULTIPART_APPLEDOUBLE )
2540 {
@@ -30,7 +45,7 @@ diff -ur a/MIME_headers.c b/MIME_headers.c
3045 snprintf( hinfo->filename, sizeof(hinfo->filename), "%s", tmp );
3146 snprintf( hinfo->name, sizeof(hinfo->name), "%s", tmp );
3247 }
33- @@ -3034,7 +3034,7 @@
48+ @@ -3034,7 +3034,7 @@ int MIMEH_headers_get( struct MIMEH_header_info *hinfo, FFGET_FILE *f )
3449
3550 // Initialise header defects array.
3651 hinfo->header_defect_count = 0;
@@ -39,15 +54,11 @@ diff -ur a/MIME_headers.c b/MIME_headers.c
3954
4055 snprintf( hinfo->content_type_string, _MIMEH_CONTENT_TYPE_MAX , "text/plain" );
4156
42- @@ -3238,4 +3238,3 @@
43- }
44-
45- //----------------------END
46- -
47- diff -ur a/altermime.c b/altermime.c
48- --- a/altermime.c 2023-09-27 11:10:46.846337912 +0000
49- +++ b/altermime.c 2023-09-27 11:11:42.727508707 +0000
50- @@ -375,7 +375,7 @@
57+ diff --git a/altermime.c b/altermime.c
58+ index 49b46e8..dcbd599 100644
59+ --- a/altermime.c
60+ +++ b/altermime.c
61+ @@ -375,7 +375,7 @@ int main( int argc, char **argv )
5162
5263 glb.input_is_stdin = 1;
5364
@@ -56,10 +67,11 @@ diff -ur a/altermime.c b/altermime.c
5667 // free(glb.input_file);
5768
5869 glb.input_file = strdup(scratch);
59- diff -ur a/mime_alter.c b/mime_alter.c
60- --- a/mime_alter.c 2023-09-27 10:54:05.861626358 +0000
61- +++ b/mime_alter.c 2023-09-27 10:55:24.479331955 +0000
62- @@ -1543,7 +1543,7 @@
70+ diff --git a/mime_alter.c b/mime_alter.c
71+ index 01db5f7..1e638b4 100644
72+ --- a/mime_alter.c
73+ +++ b/mime_alter.c
74+ @@ -1543,7 +1543,7 @@ int AM_add_disclaimer_insert_html( struct AM_disclaimer_details *dd, FFGET_FILE
6375
6476 if (dd->boundary_found == 1)
6577 {
@@ -68,9 +80,41 @@ diff -ur a/mime_alter.c b/mime_alter.c
6880 boundary_length = strlen(boundary);
6981 }
7082
71- diff -ur a/mime_alter.h b/mime_alter.h
72- --- a/mime_alter.h 2023-09-27 10:58:30.843352861 +0000
73- +++ b/mime_alter.h 2023-09-27 10:58:51.875762772 +0000
83+ @@ -3378,13 +3378,13 @@ int AM_insert_Xheader( char *fname, char *xheader)
84+ snprintf(tpn, sizeof(tpn), "%s",fname);
85+
86+ do {
87+ - if (strlen(tpn) < (sizeof(tpn) -2))
88+ + size_t tpn_len = strlen(tpn);
89+ + if (tpn_len < (sizeof(tpn) -2))
90+ {
91+ /** Changed the temp filename suffix chat to a hypen because under
92+ ** windows appending multiple .'s results in a filename that isn't
93+ ** acceptable - Thanks to Nico for bringing this to my attention **/
94+ - // LOGGER_log("%s:%d:AM_insert_Xheader:NOTICE: Adjusting temp file name for header insert",FL);
95+ - snprintf(tpn, sizeof(tpn),"%sX", tpn);
96+ + strncat(tpn, "X", sizeof(tpn) -2);
97+
98+ } else {
99+ LOGGER_log("%s:%d:AM_insert_Xheader:ERROR: Temporary file name string buffer out of space!",FL);
100+ @@ -3516,9 +3516,10 @@ int AM_alter_header( char *filename, char *header, char *change, int change_mode
101+ snprintf(tpn, sizeof(tpn), "%s",filename);
102+
103+ do {
104+ - if (strlen(tpn) < (sizeof(tpn) -2))
105+ - {
106+ - snprintf(tpn, sizeof(tpn),"%sX", tpn);
107+ + size_t tpn_len = strlen(tpn);
108+ +
109+ + if (tpn_len < (sizeof(tpn) -2)) {
110+ + strncat(tpn, "X", sizeof(tpn) -2);
111+ }
112+ else
113+ {
114+ diff --git a/mime_alter.h b/mime_alter.h
115+ index 933c657..c7e121b 100644
116+ --- a/mime_alter.h
117+ +++ b/mime_alter.h
74118@@ -23,6 +23,8 @@
75119 #define AM_NULLIFY_MATCH_MODE_FILENAME 1
76120 #define AM_NULLIFY_MATCH_MODE_CONTENT_TYPE 2
@@ -80,10 +124,20 @@ diff -ur a/mime_alter.h b/mime_alter.h
80124 struct AM_disclaimer_details {
81125
82126 // File details
83- diff -ur a/pldstr.c b/pldstr.c
84- --- a/pldstr.c 2023-09-27 11:01:32.718946199 +0000
85- +++ b/pldstr.c 2023-09-27 11:02:13.067756480 +0000
86- @@ -297,7 +297,7 @@
127+ @@ -33,7 +35,7 @@ struct AM_disclaimer_details {
128+ int content_type;
129+ int content_encoding;
130+ int boundary_found;
131+ - char boundary[1024];
132+ + char boundary[AM_BOUNDARY_BUFFER_SIZE];
133+
134+ //
135+
136+ diff --git a/pldstr.c b/pldstr.c
137+ index fdacdd2..ca29de3 100644
138+ --- a/pldstr.c
139+ +++ b/pldstr.c
140+ @@ -297,7 +297,7 @@ char *PLD_strtok( struct PLD_strtok *st, char *line, char *delimeters )
87141
88142 result = st->start;
89143
@@ -92,10 +146,11 @@ diff -ur a/pldstr.c b/pldstr.c
92146 {
93147 stop = strpbrk( st->start, delimeters ); /* locate our next delimeter */
94148
95- diff -ur a/qpe.c b/qpe.c
96- --- a/qpe.c 2023-09-27 11:07:41.034466948 +0000
97- +++ b/qpe.c 2023-09-27 11:08:28.903460520 +0000
98- @@ -106,7 +106,7 @@
149+ diff --git a/qpe.c b/qpe.c
150+ index 249fb9d..8c2f461 100644
151+ --- a/qpe.c
152+ +++ b/qpe.c
153+ @@ -106,7 +106,7 @@ int qp_encode( char *out, size_t out_size, char *in, size_t in_size, char *line_
99154 char charout[4];
100155 int charout_size=0;
101156
@@ -104,3 +159,6 @@ diff -ur a/qpe.c b/qpe.c
104159 if (linestart == NULL) {
105160 linestart = in;
106161 } else {
162+ - -
163+ 2.34.1
164+
0 commit comments