$NetBSD: patch-ae,v 1.7 2025/10/12 00:57:39 mrg Exp $ - use required standard headers - make sure index() is available - don't provide own declarations of standard functions - fix path to sendmail (although, is this really adequately MI?) - buffer length fix - port for GCC 14 --- metamail/splitmail.c.orig 1994-01-31 14:23:14.000000000 -0800 +++ metamail/splitmail.c 2025-10-11 17:24:38.158624097 -0700 @@ -21,14 +21,26 @@ WITHOUT ANY EXPRESS OR IMPLIED WARRANTIE ******************************************************* */ #include +#include +#include +#include #include #include #include #include #include +#ifndef index +#define index(a, b) strchr(a, b) +#endif + #define MINCHUNKSIZE 20000 /* Better be enough to hold the headers, or we die! */ -extern char *malloc(), *index(), *getmyname(); +extern char *getmyname(); + +int ShareThisHeader(); +void HandleOnePart(); +int ULstrcmp(); +int IllegalContentType(); #ifdef AMIGA #define Prototype extern @@ -40,11 +52,11 @@ extern char *malloc(), *index(), *getmyn #define NORMALDELIVERYCMD NormalDeliveryCmd #define VERBOSEDELIVERYCMD VerboseDeliveryCmd #else -extern char *getenv(); -#define NORMALDELIVERYCMD "/usr/lib/sendmail -t -oi" -#define VERBOSEDELIVERYCMD "/usr/lib/sendmail -t -v -oi" +#define NORMALDELIVERYCMD "/usr/sbin/sendmail -t -oi" +#define VERBOSEDELIVERYCMD "/usr/sbin/sendmail -t -v -oi" #endif +void usageexit() { fprintf(stderr, "Usage: splitmail [-d] [-v] [-s splitsize] [-i id-suffix] [-p prefix] [file-name]\n"); exit(-1); @@ -67,7 +79,9 @@ char *s; } } +int main(argc, argv) +int argc; char **argv; { int i, DoDeliver=0, SplitSize=DEFAULT_SPLIT_SIZE, dum, InNewline=1, bytesread, whichpart=1, Verbose=0, numparts = -1, c; @@ -194,7 +208,7 @@ char **argv; s = endofheader(from); /* would be index(from, '\n'), but need to check for continuation lines */ *s = '\0'; - if (ShareThisHeader(from, SubjectBuf, &OrigID)) { + if (ShareThisHeader(from, SubjectBuf, sizeof(SubjectBuf), &OrigID)) { strcat(SharedHeaders, from); strcat(SharedHeaders, "\n"); } @@ -238,6 +252,7 @@ char **argv; return(0); } +void HandleOnePart(DoDeliver, deliverycmd, prefix, numparts, whichpart, SharedHeaders, SubjectBuf, id, MessageID, bigbuf, OrigID) int DoDeliver, numparts, whichpart; char *deliverycmd, *prefix, *SharedHeaders, *SubjectBuf, *id, *MessageID, *bigbuf, *OrigID; @@ -339,9 +354,11 @@ static char *SharedHeads[] = { NULL }; -ShareThisHeader(s, SubjectBuf, OrigID) +int +ShareThisHeader(s, SubjectBuf, size, OrigID) char *s; char *SubjectBuf; +size_t size; char **OrigID; { int i; @@ -361,7 +378,8 @@ char **OrigID; } if (!ULstrcmp(s, "subject")) { *colon = ':'; - strcpy(SubjectBuf, ++colon); + strncpy(SubjectBuf, ++colon, size); + SubjectBuf[size - 1] = '\0'; return(0); } if (!ULstrcmp(s, "content-type")) { @@ -379,6 +397,7 @@ char **OrigID; static char *tspecials = "()<>@,;:\\\"/[]?.="; +int IllegalContentType(ctype) char *ctype; {