Fixed too low malloc in clencode function
This commit is contained in:
parent
f69200f40f
commit
0919143543
@ -383,7 +383,7 @@ void chartran_close(void)
|
|||||||
*/
|
*/
|
||||||
char *chartran(char *input)
|
char *chartran(char *input)
|
||||||
{
|
{
|
||||||
static char outbuf[1024];
|
static char outbuf[4096];
|
||||||
static char temp[4096];
|
static char temp[4096];
|
||||||
size_t rc, inSize, outSize;
|
size_t rc, inSize, outSize;
|
||||||
char *in, *out;
|
char *in, *out;
|
||||||
|
@ -525,12 +525,12 @@ char *clencode(char *s)
|
|||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return 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);
|
Syslog('+', "clencode: out of memory:string too long:\"%s\"", s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
for (p = s, q = buf; *p != '\0';) {
|
for (p = s, q = buf; *p != '\0';) {
|
||||||
if ((! isascii(*p)) || (*p == ',') || (*p == ';') || (*p == '"')) {
|
if (( ! isascii(*p)) || (*p == '%') || (*p == ',') || (*p == ';') || (*p == '"')) {
|
||||||
*q++ = '\\';
|
*q++ = '\\';
|
||||||
*q++ = Base16Code[(*p >> 4) & 0x0f];
|
*q++ = Base16Code[(*p >> 4) & 0x0f];
|
||||||
*q++ = Base16Code[*p & 0x0f];
|
*q++ = Base16Code[*p & 0x0f];
|
||||||
|
@ -24,7 +24,7 @@ int tracing = TRUE; /* Trace macro evalution */
|
|||||||
/* Local variables. */
|
/* Local variables. */
|
||||||
|
|
||||||
#define MAXARGS 10 /* Maximum arguments to a macro */
|
#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 MAXDEPTH 32 /* Maximum recursion depth for eval */
|
||||||
|
|
||||||
#define MACROCHAR '@' /* Macro trigger character */
|
#define MACROCHAR '@' /* Macro trigger character */
|
||||||
|
@ -520,7 +520,7 @@ void HtmlIndex(char *Lang)
|
|||||||
int AreaNr = 0, j, k, x = 0, isthumb;
|
int AreaNr = 0, j, k, x = 0, isthumb;
|
||||||
int aTotal = 0, inArea = 0, filenr;
|
int aTotal = 0, inArea = 0, filenr;
|
||||||
char *sAreas, *fn, *temp;
|
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;
|
time_t last = 0L, later, db_time, obj_time;
|
||||||
int fileptr = 0, fileptr1 = 0;
|
int fileptr = 0, fileptr1 = 0;
|
||||||
struct _fdbarea *fdb_area = NULL;
|
struct _fdbarea *fdb_area = NULL;
|
||||||
@ -707,9 +707,8 @@ void HtmlIndex(char *Lang)
|
|||||||
k += 1;
|
k += 1;
|
||||||
}
|
}
|
||||||
html_massage(fdb.Desc[j], linebuf, 1024);
|
html_massage(fdb.Desc[j], linebuf, 1024);
|
||||||
// strncpy(linebuf, fdb.Desc[j], 1024);
|
|
||||||
strncpy(outbuf, chartran(linebuf), 1024);
|
strncpy(outbuf, chartran(linebuf), 1024);
|
||||||
strncat(desc, outbuf, 6400 -k);
|
strncat(desc, outbuf, 19200 -k);
|
||||||
k += strlen(outbuf);
|
k += strlen(outbuf);
|
||||||
}
|
}
|
||||||
MacroVars("m", "s", desc);
|
MacroVars("m", "s", desc);
|
||||||
|
@ -126,7 +126,7 @@ int kludgewrite(char *s, FILE *fp)
|
|||||||
int rfc2ftn(FILE *fp, faddr *recipient)
|
int rfc2ftn(FILE *fp, faddr *recipient)
|
||||||
{
|
{
|
||||||
char sbe[128], *p, *q, *temp, *origin, newsubj[4 * (MAXSUBJ+1)], *oldsubj, *acup_a = NULL, *charset = NULL;
|
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;
|
rfcmsg *msg = NULL, *tmsg, *tmp;
|
||||||
ftnmsg *fmsg = NULL;
|
ftnmsg *fmsg = NULL;
|
||||||
FILE *ofp;
|
FILE *ofp;
|
||||||
@ -248,6 +248,7 @@ int rfc2ftn(FILE *fp, faddr *recipient)
|
|||||||
charset = xstrcpy((char *)"iso-8859-1");
|
charset = xstrcpy((char *)"iso-8859-1");
|
||||||
Syslog('m', "No charset, setting default to 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 ((p = hdr((char *)"Message-ID",msg))) {
|
||||||
if (!removemsgid)
|
if (!removemsgid)
|
||||||
@ -331,12 +332,13 @@ int rfc2ftn(FILE *fp, faddr *recipient)
|
|||||||
if (fmsg->to)
|
if (fmsg->to)
|
||||||
hdrsize += (fmsg->to->name)?strlen(fmsg->to->name):0;
|
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
|
* Setup charset conversion
|
||||||
*/
|
*/
|
||||||
chartran_init(charset,getrfcchrs(msgs.Charset), 'm');
|
chartran_init(get_ic_rfc(chars_in), get_ic_ftn(chars_out), 'm');
|
||||||
|
|
||||||
do {
|
do {
|
||||||
Syslog('m', "rfc2ftn: split loop, splitpart = %d", splitpart);
|
Syslog('m', "rfc2ftn: split loop, splitpart = %d", splitpart);
|
||||||
|
@ -625,7 +625,7 @@ char *clencode(char *s)
|
|||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return 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);
|
Syslog('+', "clencode: out of memory:string too long:\"%s\"", s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user