mirror of
https://github.com/Cisco-Talos/clamav.git
synced 2026-05-07 23:26:27 -04:00
improve I/O error handling in cli_filetype2 (bb#818)
git-svn: trunk@3605
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
Mon Feb 11 11:09:10 CET 2008 (tk)
|
||||
---------------------------------
|
||||
* libclamav/filetypes.c: improve I/O error handling in cli_filetype2 (bb#818)
|
||||
|
||||
Sun Feb 10 10:28:55 EET 2008 (edwin)
|
||||
------------------------------------
|
||||
* configure, configure.in: don't use EXIT_SUCCESS if <stdlib.h> is not
|
||||
|
||||
@@ -149,8 +149,11 @@ cli_file_t cli_filetype2(int desc, const struct cl_engine *engine)
|
||||
}
|
||||
|
||||
memset(smallbuff, 0, sizeof(smallbuff));
|
||||
if((bread = read(desc, smallbuff, MAGIC_BUFFER_SIZE)) > 0)
|
||||
ret = cli_filetype(smallbuff, bread, engine);
|
||||
bread = cli_readn(desc, smallbuff, MAGIC_BUFFER_SIZE);
|
||||
if(bread == -1)
|
||||
return CL_TYPE_ERROR;
|
||||
|
||||
ret = cli_filetype(smallbuff, bread, engine);
|
||||
|
||||
if(ret >= CL_TYPE_TEXT_ASCII && ret <= CL_TYPE_BINARY_DATA) {
|
||||
/* HTML files may contain special characters and could be
|
||||
@@ -230,7 +233,7 @@ cli_file_t cli_filetype2(int desc, const struct cl_engine *engine)
|
||||
return ret;
|
||||
|
||||
lseek(desc, 0, SEEK_SET);
|
||||
if((bread = read(desc, bigbuff, 37638)) > 0) {
|
||||
if((bread = cli_readn(desc, bigbuff, 37638)) > 0) {
|
||||
|
||||
bigbuff[bread] = 0;
|
||||
|
||||
|
||||
@@ -1838,6 +1838,10 @@ int cli_magic_scandesc(int desc, cli_ctx *ctx)
|
||||
|
||||
lseek(desc, 0, SEEK_SET);
|
||||
type = cli_filetype2(desc, ctx->engine);
|
||||
if(type == CL_TYPE_ERROR) {
|
||||
cli_dbgmsg("cli_magic_scandesc: cli_filetype2 returned CL_TYPE_ERROR\n");
|
||||
return CL_EIO;
|
||||
}
|
||||
lseek(desc, 0, SEEK_SET);
|
||||
|
||||
if(type != CL_TYPE_IGNORED && ctx->engine->sdb) {
|
||||
|
||||
Reference in New Issue
Block a user