diff --git a/clamd/scanner.c b/clamd/scanner.c index 3195a610df..e11e66ca25 100644 --- a/clamd/scanner.c +++ b/clamd/scanner.c @@ -268,6 +268,7 @@ cl_error_t scan_callback(STATBUF *sb, char *filename, const char *msg, enum cli_ context.virsize = 0; context.scandata = scandata; ret = cl_scanfile_callback(filename, &virname, &scandata->scanned, scandata->engine, scandata->options, &context); + fprintf(stderr, "%s::%d::ret == CL_EMEM = %d\n", __FUNCTION__, __LINE__, ret == CL_EMEM); thrmgr_setactivetask(NULL, NULL); if (thrmgr_group_need_terminate(scandata->conn->group)) { @@ -275,11 +276,15 @@ cl_error_t scan_callback(STATBUF *sb, char *filename, const char *msg, enum cli_ logg(LOGG_DEBUG, "Client disconnected while scanjob was active\n"); return ret == CL_ETIMEOUT ? ret : CL_BREAK; } + fprintf(stderr, "%s::%d::ret == CL_EMEM = %d\n", __FUNCTION__, __LINE__, ret == CL_EMEM); if ((ret == CL_VIRUS) && (virname == NULL)) { logg(LOGG_DEBUG, "%s: reported CL_VIRUS but no virname returned!\n", filename); + fprintf(stderr, "%s::%d::ret == CL_EMEM = %d\n", __FUNCTION__, __LINE__, ret == CL_EMEM); ret = CL_EMEM; + fprintf(stderr, "%s::%d::ret == CL_EMEM = %d\n", __FUNCTION__, __LINE__, ret == CL_EMEM); } + fprintf(stderr, "%s::%d::ret == CL_EMEM = %d\n", __FUNCTION__, __LINE__, ret == CL_EMEM); if (ret == CL_EACCES) { if (conn_reply(scandata->conn, filename, "Access denied.", "ERROR") == -1) { @@ -291,8 +296,10 @@ cl_error_t scan_callback(STATBUF *sb, char *filename, const char *msg, enum cli_ free(filename); return CL_SUCCESS; } + fprintf(stderr, "%s::%d::ret == CL_EMEM = %d\n", __FUNCTION__, __LINE__, ret == CL_EMEM); if (ret == CL_VIRUS) { + fprintf(stderr, "%s::%d::ret == CL_EMEM = %d\n", __FUNCTION__, __LINE__, ret == CL_EMEM); if (scandata->options->general & CL_SCAN_GENERAL_ALLMATCHES || (scandata->infected && scandata->options->general & CL_SCAN_GENERAL_HEURISTIC_PRECEDENCE)) { if (optget(scandata->opts, "PreludeEnable")->enabled) { @@ -316,12 +323,14 @@ cl_error_t scan_callback(STATBUF *sb, char *filename, const char *msg, enum cli_ logg(LOGG_INFO, "%s: %s FOUND\n", filename, virname); } } else if (ret != CL_CLEAN) { + fprintf(stderr, "%s::%d::ret == CL_EMEM = %d\n", __FUNCTION__, __LINE__, ret == CL_EMEM); scandata->errors++; if (conn_reply(scandata->conn, filename, cl_strerror(ret), "ERROR") == -1) { free(filename); return CL_ETIMEOUT; } - logg(LOGG_INFO, "%s: %s ERROR\n", filename, cl_strerror(ret)); +fprintf(stderr, "%s::%d::ret == CL_EMEM = %d\n", __FUNCTION__, __LINE__, ret == CL_EMEM); + logg(LOGG_INFO, "%s::%d::%s: %s ERROR\n", __FUNCTION__, __LINE__, filename, cl_strerror(ret)); } else if (logok) { logg(LOGG_INFO, "%s: OK\n", filename); } diff --git a/clamd/server-th.c b/clamd/server-th.c index a7b5813c2a..57a6b9241a 100644 --- a/clamd/server-th.c +++ b/clamd/server-th.c @@ -1375,6 +1375,8 @@ int recvloop(int *socketds, unsigned nsockets, struct cl_engine *engine, unsigne logg(LOGG_INFO, "Self checking every %u seconds.\n", selfchk); } + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); + logg(LOGG_DEBUG, "Listening daemon: PID: %u\n", (unsigned int)getpid()); max_threads = optget(opts, "MaxThreads")->numarg; max_queue = optget(opts, "MaxQueue")->numarg; @@ -1383,6 +1385,7 @@ int recvloop(int *socketds, unsigned nsockets, struct cl_engine *engine, unsigne #if !defined(_WIN32) && defined(RLIMIT_NOFILE) if (getrlimit(RLIMIT_NOFILE, &rlim) == 0) { + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); /* don't warn if default value is too high, silently fix it */ unsigned maxrec; int max_max_queue; @@ -1402,6 +1405,7 @@ int recvloop(int *socketds, unsigned nsockets, struct cl_engine *engine, unsigne ** flag */ + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); #if defined(_LP64) solaris_has_extended_stdio++; #endif @@ -1427,6 +1431,7 @@ int recvloop(int *socketds, unsigned nsockets, struct cl_engine *engine, unsigne ** as the default is usually 256 */ + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); if (solaris_has_extended_stdio) { rlim_t saved_soft_limit = rlim.rlim_cur; @@ -1439,6 +1444,7 @@ int recvloop(int *socketds, unsigned nsockets, struct cl_engine *engine, unsigne } /* If 64bit or has extended stdio */ #endif + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); opt = optget(opts, "MaxRecursion"); maxrec = opt->numarg; max_max_queue = rlim.rlim_cur - maxrec * max_threads - clamdfiles + max_threads; @@ -1466,7 +1472,9 @@ int recvloop(int *socketds, unsigned nsockets, struct cl_engine *engine, unsigne } #endif logg(LOGG_DEBUG, "MaxQueue set to: %d\n", max_queue); + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); acceptdata.max_queue = max_queue; + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); #ifndef _WIN32 /* set up signal handling */ @@ -1504,6 +1512,7 @@ int recvloop(int *socketds, unsigned nsockets, struct cl_engine *engine, unsigne sigaction(SIGUSR2, &sigact, NULL); #endif + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); idletimeout = optget(opts, "IdleTimeout")->numarg; for (i = 0; i < nsockets; i++) @@ -1530,17 +1539,20 @@ int recvloop(int *socketds, unsigned nsockets, struct cl_engine *engine, unsigne exit(-1); } #endif + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); if ((thr_pool = thrmgr_new(max_threads, idletimeout, max_queue, scanner_thread)) == NULL) { logg(LOGG_ERROR, "thrmgr_new failed\n"); exit(-1); } + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); if (pthread_create(&accept_th, NULL, acceptloop_th, &acceptdata)) { logg(LOGG_ERROR, "pthread_create failed\n"); exit(-1); } + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); time(&start_time); for (;;) { int new_sd; @@ -1573,6 +1585,7 @@ int recvloop(int *socketds, unsigned nsockets, struct cl_engine *engine, unsigne } if (fds->nfds) i = (rr_last + 1) % fds->nfds; + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); for (j = 0; j < fds->nfds && new_sd >= 0; j++, i = (i + 1) % fds->nfds) { size_t pos = 0; int error = 0; @@ -1613,8 +1626,10 @@ int recvloop(int *socketds, unsigned nsockets, struct cl_engine *engine, unsigne buf->mode = MODE_COMMAND; logg(LOGG_DEBUG_NV, "mode -> MODE_COMMAND\n"); } + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); while (!error && buf->fd != -1 && buf->buffer && pos < buf->off && buf->mode != MODE_WAITANCILL) { + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); client_conn_t conn; const char *cmd = NULL; int rc; @@ -1635,8 +1650,10 @@ int recvloop(int *socketds, unsigned nsockets, struct cl_engine *engine, unsigne conn.mode = buf->mode; conn.term = buf->term; + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); /* Parse & dispatch command */ cmd = parse_dispatch_cmd(&conn, buf, &pos, &error, opts, readtimeout); + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); if (conn.mode == MODE_COMMAND && !cmd) break; @@ -1658,8 +1675,10 @@ int recvloop(int *socketds, unsigned nsockets, struct cl_engine *engine, unsigne if (error && error != CL_ETIMEOUT) { conn_reply_error(&conn, "Error processing command."); } + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); } if (error) { + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); if (buf->dumpfd != -1) { close(buf->dumpfd); if (buf->dumpname) { @@ -1684,6 +1703,7 @@ int recvloop(int *socketds, unsigned nsockets, struct cl_engine *engine, unsigne } pthread_mutex_unlock(fds->buf_mutex); + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); /* handle progexit */ pthread_mutex_lock(&exit_mutex); if (progexit) { @@ -1708,6 +1728,7 @@ int recvloop(int *socketds, unsigned nsockets, struct cl_engine *engine, unsigne } pthread_mutex_unlock(&exit_mutex); + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); /* SIGHUP */ if (sighup) { logg(LOGG_INFO, "SIGHUP caught: re-opening log file.\n"); @@ -1716,6 +1737,7 @@ int recvloop(int *socketds, unsigned nsockets, struct cl_engine *engine, unsigne if (!logg_file && (opt = optget(opts, "LogFile"))->enabled) logg_file = opt->strarg; } + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); /* SelfCheck */ if (selfchk) { @@ -1729,6 +1751,7 @@ int recvloop(int *socketds, unsigned nsockets, struct cl_engine *engine, unsigne time(&start_time); } } + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); /* DB reload */ pthread_mutex_lock(&reload_mutex); @@ -1778,7 +1801,10 @@ int recvloop(int *socketds, unsigned nsockets, struct cl_engine *engine, unsigne } else { pthread_mutex_unlock(&reload_mutex); } + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); } + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); + logg(LOGG_INFO, "%s::%d\n", __FUNCTION__, __LINE__); pthread_mutex_lock(&exit_mutex); progexit = 1; diff --git a/clamdscan/client.c b/clamdscan/client.c index 7b7a5ae76d..782030f70c 100644 --- a/clamdscan/client.c +++ b/clamdscan/client.c @@ -313,8 +313,10 @@ static int client_scan(const char *file, int scantype, int *infected, int *err, char *real_path = NULL; char *fullpath = NULL; + fprintf(stderr, "%s::%d\n", __FUNCTION__, __LINE__); /* Convert relative path to fullpath */ fullpath = makeabs(file); + fprintf(stderr, "%s::%d\n", __FUNCTION__, __LINE__); /* Convert fullpath to the real path (evaluating symlinks and . and ..). Doing this early on will ensure that the scan results will appear consistent @@ -325,13 +327,21 @@ static int client_scan(const char *file, int scantype, int *infected, int *err, free(fullpath); fullpath = real_path; } + fprintf(stderr, "%s::%d\n", __FUNCTION__, __LINE__); if (!fullpath) return 0; - if (!session) + if (!session) { + fprintf(stderr, "%s::%d\n", __FUNCTION__, __LINE__); ret = serial_client_scan(fullpath, scantype, infected, err, maxlevel, flags); - else + fprintf(stderr, "%s::%d\n", __FUNCTION__, __LINE__); + } + else { + fprintf(stderr, "%s::%d\n", __FUNCTION__, __LINE__); ret = parallel_client_scan(fullpath, scantype, infected, err, maxlevel, flags); + fprintf(stderr, "%s::%d\n", __FUNCTION__, __LINE__); + } + fprintf(stderr, "%s::%d\n", __FUNCTION__, __LINE__); free(fullpath); return ret; } diff --git a/clamdscan/proto.c b/clamdscan/proto.c index 0f14419d4f..052259dbfa 100644 --- a/clamdscan/proto.c +++ b/clamdscan/proto.c @@ -184,7 +184,9 @@ int serial_client_scan(char *file, int scantype, int *infected, int *err, int ma cdata.scantype = scantype; data.data = &cdata; + fprintf(stderr, "%s::%d\n", __FUNCTION__, __LINE__); ftw = cli_ftw(file, flags, maxlevel ? maxlevel : INT_MAX, serial_callback, &data, ftw_chkpath); + fprintf(stderr, "%s::%d\n", __FUNCTION__, __LINE__); *infected += cdata.infected; *err += cdata.errors; diff --git a/libclamav/others.c b/libclamav/others.c index dd7adba60b..d63beb14bc 100644 --- a/libclamav/others.c +++ b/libclamav/others.c @@ -388,7 +388,7 @@ const char *cl_strerror(cl_error_t clerror) case CL_EMAP: return "Can't map file into memory"; case CL_EMEM: - return "Can't allocate memory"; + return "Can't allocate memory "; case CL_ETIMEOUT: return "Exceeded time limit"; /* internal (needed for debug messages) */ diff --git a/libclamav/scanners.c b/libclamav/scanners.c index a9fb272e79..80716a210d 100644 --- a/libclamav/scanners.c +++ b/libclamav/scanners.c @@ -5737,8 +5737,14 @@ cl_error_t cl_scandesc_callback(int desc, const char *filename, const char **vir if ((engine->maxfilesize > 0) && ((uint64_t)sb.st_size > engine->maxfilesize)) { cli_dbgmsg("cl_scandesc_callback: File too large (" STDu64 " bytes), ignoring\n", (uint64_t)sb.st_size); if (scanoptions->heuristic & CL_SCAN_HEURISTIC_EXCEEDS_MAX) { - if (engine->cb_virus_found) + if (engine->cb_virus_found) { +fprintf(stderr, "%s::%d::In if statement for Heuristics.Limits.Exceeded.MaxFileSize\n", __FUNCTION__, __LINE__); engine->cb_virus_found(desc, "Heuristics.Limits.Exceeded.MaxFileSize", context); + if (virname){ + *virname = "Heuristics.Limits.Exceeded.MaxFileSize"; + } + } +fprintf(stderr, "%s::%d::Setting status to CL_VIRUS\n", __FUNCTION__, __LINE__); //exit(11); status = CL_VIRUS; } else { status = CL_CLEAN; @@ -5752,11 +5758,13 @@ cl_error_t cl_scandesc_callback(int desc, const char *filename, const char **vir if (NULL == (map = fmap(desc, 0, sb.st_size, filename_base))) { cli_errmsg("CRITICAL: fmap() failed\n"); +fprintf(stderr, "%s::%d::returning CL_EMEM\n", __FUNCTION__, __LINE__); status = CL_EMEM; goto done; } status = scan_common(map, filename, virname, scanned, engine, scanoptions, context); +fprintf(stderr, "%s::%d::returning CL_EMEM = %d\n", __FUNCTION__, __LINE__, status == CL_EMEM); done: if (NULL != map) { @@ -5838,6 +5846,11 @@ cl_error_t cl_scanfile_callback(const char *filename, const char **virname, unsi ret = cl_scandesc_callback(fd, filename, virname, scanned, engine, scanoptions, context); close(fd); + //logg(LOGG_ERROR, "%s::%d\n", __FUNCTION__, __LINE__); +fprintf(stderr, "%s::%d::ret == CL_EMEM = %d\n", __FUNCTION__, __LINE__, CL_EMEM == ret); +fprintf(stderr, "%s::%d::ret == CL_VIRUS = %d\n", __FUNCTION__, __LINE__, CL_VIRUS == ret); +fprintf(stderr, "%s::%d::ret = %d\n", __FUNCTION__, __LINE__, ret); + return ret; }