ClamAV-Clamd

 view release on metacpan or  search on metacpan

include/clamav/clamd_abi_impl.h  view on Meta::CPAN

    PERL_UNUSED_CONTEXT;
    if (!g) return NULL;
    s = cca_scan_new();
    /*
     # uncoverable branch true
     # uncoverable condition left count:1 */
    if (!s) return NULL;

    {
        cc_stat_t st;
        if (cc_fstat(fd, &st) < 0) {
            cc_err_set(&s->err, CC_ERR_IO, "fstat", strerror(errno));
            s->rc = CC_ERR_IO; return s;
        }
        if (!CC_S_ISREG(st.st_mode)) {
            cc_err_set(&s->err, CC_ERR_NOTREG, "not a regular file", NULL);
            s->rc = CC_ERR_NOTREG; return s;
        }
        if (g->t.max_size && (size_t)st.st_size > g->t.max_size) {
            cc_err_set(&s->err, CC_ERR_TOOBIGLOC,
                       "larger than max_size; refused without scanning", NULL);

include/clamav/clamd_compat.h  view on Meta::CPAN

#  include <poll.h>
#endif

/* The file side. The underscore names on Windows are deliberate: perl
 * renames the plain ones (read, open, close, fstat) there, and its fstat
 * wants perl's own stat struct. The descriptor is opened binary, or the
 * C runtime rewrites line endings and stops at ^Z - in a scanner, that
 * is a file clamd never saw the whole of. */
#ifdef _WIN32
   typedef struct _stat64 cc_stat_t;
#  define cc_fstat(fd, st)   _fstat64((fd), (st))
#  define cc_open_ro(path)   _open((path), _O_RDONLY | _O_BINARY)
#  define cc_read_fd(fd, b, n) _read((fd), (b), (unsigned int)(n))
#  define cc_close_fd(fd)    _close(fd)
#  define CC_S_ISREG(m)      (((m) & _S_IFMT) == _S_IFREG)
#else
   typedef struct stat cc_stat_t;
#  define cc_fstat(fd, st)   fstat((fd), (st))
#  define cc_open_ro(path)   open((path), O_RDONLY)
#  define cc_read_fd(fd, b, n) read((fd), (b), (n))
#  define cc_close_fd(fd)    close(fd)
#  define CC_S_ISREG(m)      S_ISREG(m)
#endif

/* Writing to a socket the peer has closed raises SIGPIPE, whose default
 * disposition kills the process. A library that takes down its caller
 * because clamd hung up is not usable inside a server, and clamd hangs
 * up routinely - it does exactly that when a stream exceeds

include/clamav/clamd_scan.h  view on Meta::CPAN

     * asked for something impossible, so the client has to know.
     *
     * Same on any platform without SCM_RIGHTS. Both fall back to
     * INSTREAM, which is correct but expensive: the file now crosses the
     * socket in full. That is why the transport is reported. */
    mode = (CC_HAVE_FD_PASSING && t->path) ? CC_TRANSPORT_FILDES
                                           : CC_TRANSPORT_INSTREAM;

    {
        cc_stat_t st;
        if (cc_fstat(fd, &st) < 0) {
            cc_err_set(err, CC_ERR_IO, "fstat", strerror(errno));
            return CC_ERR_IO;
        }
        if (!CC_S_ISREG(st.st_mode)) {
            cc_err_set(err, CC_ERR_NOTREG, "not a regular file", NULL);
            return CC_ERR_NOTREG;
        }
        if (t->max_size && (size_t)st.st_size > t->max_size) {
            cc_err_set(err, CC_ERR_TOOBIGLOC,
                       "larger than max_size; refused without scanning", NULL);



( run in 2.707 seconds using v1.01-cache-2.11-cpan-eb134014566 )