reduce stack usage of cli_scanscript (bb #819)

git-svn: trunk@3595
This commit is contained in:
Török Edvin
2008-02-08 12:06:24 +00:00
parent efac2f09b7
commit 2a138cc577
2 changed files with 13 additions and 3 deletions

View File

@@ -1,3 +1,7 @@
Fri Feb 8 13:50:18 EET 2008 (edwin)
------------------------------------
* reduce stack usage of cli_scanscript (bb #819)
Thu Feb 7 22:30:51 EET 2008 (edwin)
------------------------------------
* clamd: (bb #803)

View File

@@ -1068,14 +1068,14 @@ static int cli_scanhtml(int desc, cli_ctx *ctx)
static int cli_scanscript(int desc, cli_ctx *ctx)
{
unsigned char buff[FILEBUFF];
unsigned char normalized[SCANBUFF];
unsigned char* normalized;
struct text_norm_state state;
struct stat sb;
char *tmpname = NULL;
int ofd = -1, ret;
ssize_t nread;
cli_dbgmsg("in cli_scantext()\n");
cli_dbgmsg("in cli_scanscript()\n");
if(fstat(desc, &sb) == -1) {
cli_errmsg("cli_scanscript: fstat() failed for descriptor %d\n", desc);
@@ -1097,7 +1097,12 @@ static int cli_scanscript(int desc, cli_ctx *ctx)
}
}
text_normalize_init(&state, normalized, sizeof(normalized));
if(!(normalized = cli_malloc(SCANBUFF))) {
cli_dbgmsg("cli_scanscript: Unable to malloc %u bytes\n", SCANBUFF);
return CL_EMEM;
}
text_normalize_init(&state, normalized, SCANBUFF);
ret = CL_CLEAN;
do {
@@ -1128,6 +1133,7 @@ static int cli_scanscript(int desc, cli_ctx *ctx)
free(tmpname);
close(ofd);
}
free(normalized);
return ret;
}