Fixed too low malloc in clencode function

This commit is contained in:
Michiel Broek 2007-02-26 21:02:30 +00:00
parent f69200f40f
commit 0919143543
6 changed files with 12 additions and 11 deletions

View File

@ -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;

View File

@ -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];

View File

@ -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 */

View File

@ -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);

View File

@ -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);

View File

@ -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;
}