From 0919143543ab0a0c1a32d02a64e69ed553ef53a2 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Mon, 26 Feb 2007 21:02:30 +0000 Subject: [PATCH] Fixed too low malloc in clencode function --- lib/charset.c | 2 +- lib/clcomm.c | 4 ++-- lib/diesel.h | 2 +- mbfido/mbfindex.c | 5 ++--- mbfido/rfc2ftn.c | 8 +++++--- mbtask/taskutil.c | 2 +- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/charset.c b/lib/charset.c index a8331187..017522b6 100644 --- a/lib/charset.c +++ b/lib/charset.c @@ -383,7 +383,7 @@ void chartran_close(void) */ char *chartran(char *input) { - static char outbuf[1024]; + static char outbuf[4096]; static char temp[4096]; size_t rc, inSize, outSize; char *in, *out; diff --git a/lib/clcomm.c b/lib/clcomm.c index 9ead86c4..44f2c037 100644 --- a/lib/clcomm.c +++ b/lib/clcomm.c @@ -525,12 +525,12 @@ char *clencode(char *s) if (s == NULL) return NULL; - if ((buf = malloc(2 * strlen(s) + 1 * sizeof(char))) == NULL) { + if ((buf = malloc(3 * strlen(s) + 1 * sizeof(char))) == NULL) { Syslog('+', "clencode: out of memory:string too long:\"%s\"", s); return s; } for (p = s, q = buf; *p != '\0';) { - if ((! isascii(*p)) || (*p == ',') || (*p == ';') || (*p == '"')) { + if (( ! isascii(*p)) || (*p == '%') || (*p == ',') || (*p == ';') || (*p == '"')) { *q++ = '\\'; *q++ = Base16Code[(*p >> 4) & 0x0f]; *q++ = Base16Code[*p & 0x0f]; diff --git a/lib/diesel.h b/lib/diesel.h index e86590ae..380b40b1 100644 --- a/lib/diesel.h +++ b/lib/diesel.h @@ -24,7 +24,7 @@ int tracing = TRUE; /* Trace macro evalution */ /* Local variables. */ #define MAXARGS 10 /* Maximum arguments to a macro */ -#define MAXSTR 4096 /* Maximum string length */ /* Was 2560 */ +#define MAXSTR 19200 /* Maximum string length */ /* Was 2560 */ /* Size full UTF-8 code filesdesc */ #define MAXDEPTH 32 /* Maximum recursion depth for eval */ #define MACROCHAR '@' /* Macro trigger character */ diff --git a/mbfido/mbfindex.c b/mbfido/mbfindex.c index 42d3546c..f92db32c 100644 --- a/mbfido/mbfindex.c +++ b/mbfido/mbfindex.c @@ -520,7 +520,7 @@ void HtmlIndex(char *Lang) int AreaNr = 0, j, k, x = 0, isthumb; int aTotal = 0, inArea = 0, filenr; char *sAreas, *fn, *temp; - char linebuf[1024], outbuf[1024], desc[6400], namebuf[1024]; + char linebuf[1024], outbuf[1024], desc[19200], namebuf[1024]; time_t last = 0L, later, db_time, obj_time; int fileptr = 0, fileptr1 = 0; struct _fdbarea *fdb_area = NULL; @@ -707,9 +707,8 @@ void HtmlIndex(char *Lang) k += 1; } html_massage(fdb.Desc[j], linebuf, 1024); -// strncpy(linebuf, fdb.Desc[j], 1024); strncpy(outbuf, chartran(linebuf), 1024); - strncat(desc, outbuf, 6400 -k); + strncat(desc, outbuf, 19200 -k); k += strlen(outbuf); } MacroVars("m", "s", desc); diff --git a/mbfido/rfc2ftn.c b/mbfido/rfc2ftn.c index 549b94d3..0330f4d0 100644 --- a/mbfido/rfc2ftn.c +++ b/mbfido/rfc2ftn.c @@ -126,7 +126,7 @@ int kludgewrite(char *s, FILE *fp) int rfc2ftn(FILE *fp, faddr *recipient) { char sbe[128], *p, *q, *temp, *origin, newsubj[4 * (MAXSUBJ+1)], *oldsubj, *acup_a = NULL, *charset = NULL; - int i, rc, newsmode, seenlen, oldnet; + int i, rc, newsmode, seenlen, oldnet, chars_in = FTNC_NONE, chars_out = FTNC_NONE; rfcmsg *msg = NULL, *tmsg, *tmp; ftnmsg *fmsg = NULL; FILE *ofp; @@ -248,6 +248,7 @@ int rfc2ftn(FILE *fp, faddr *recipient) charset = xstrcpy((char *)"iso-8859-1"); Syslog('m', "No charset, setting default to iso-8859-1"); } + chars_in = find_rfc_charset(charset); if ((p = hdr((char *)"Message-ID",msg))) { if (!removemsgid) @@ -331,12 +332,13 @@ int rfc2ftn(FILE *fp, faddr *recipient) if (fmsg->to) hdrsize += (fmsg->to->name)?strlen(fmsg->to->name):0; - Syslog('m', "rfc2ftn: charset in: %s charset out: %s", charset,getrfcchrs(msgs.Charset)); + chars_out = msgs.Charset; + Syslog('m', "rfc2ftn: charset in: %s charset out: %s", get_ic_rfc(chars_in), get_ic_ftn(chars_out)); /* * Setup charset conversion */ - chartran_init(charset,getrfcchrs(msgs.Charset), 'm'); + chartran_init(get_ic_rfc(chars_in), get_ic_ftn(chars_out), 'm'); do { Syslog('m', "rfc2ftn: split loop, splitpart = %d", splitpart); diff --git a/mbtask/taskutil.c b/mbtask/taskutil.c index dfe2f73e..b13137eb 100644 --- a/mbtask/taskutil.c +++ b/mbtask/taskutil.c @@ -625,7 +625,7 @@ char *clencode(char *s) if (s == NULL) return NULL; - if ((buf = malloc(2 * strlen(s) + 1 * sizeof(char))) == NULL) { + if ((buf = malloc(3 * strlen(s) + 1 * sizeof(char))) == NULL) { Syslog('+', "clencode: out of memory:string too long:\"%s\"", s); return s; }