honour StreamMaxLen

git-svn-id: file:///var/lib/svn/clamav-devel/branches/clamd-proto@4705 77e5149b-7576-45b1-b177-96237e5ba77b
0.95
aCaB 17 years ago
parent 284982ca3e
commit 9877f2d823
  1. 3
      clamdscan/client.c
  2. 8
      clamdscan/proto.c

@ -66,6 +66,7 @@
int notremoved = 0, notmoved = 0;
struct sockaddr *mainsa = NULL;
int mainsasz;
unsigned long int maxstream;
static struct sockaddr_un nixsock;
static struct sockaddr_in tcpsock;
@ -256,7 +257,7 @@ int client(const struct optstruct *opts, int *infected)
{
const char *clamd_conf = optget(opts, "config-file")->strarg;
struct optstruct *clamdopts;
int remote, scantype, session = 0, errors = 0, scandash = 0, maxrec, maxstream;
int remote, scantype, session = 0, errors = 0, scandash = 0, maxrec;
if((clamdopts = optparse(clamd_conf, 0, NULL, 1, OPT_CLAMD, 0, NULL)) == NULL) {
logg("!Can't parse clamd configuration file %s\n", clamd_conf);

@ -38,6 +38,7 @@
extern struct sockaddr *mainsa;
extern int mainsasz;
extern unsigned long int maxstream;
int printinfected;
extern void (*action)(const char *);
@ -149,6 +150,7 @@ int recvln(struct RCVLN *s, char **rbol, char **reol) {
static int send_stream(int sockd, const char *filename) {
uint32_t buf[BUFSIZ/sizeof(uint32_t)];
int fd, len;
unsigned int todo = maxstream;
if(filename) {
if((fd = open(filename, O_RDONLY))<0) {
@ -160,12 +162,18 @@ static int send_stream(int sockd, const char *filename) {
if(sendln(sockd, "zINSTREAM", 10)) return 1;
while((len = read(fd, &buf[1], sizeof(buf) - sizeof(uint32_t))) > 0) {
if((unsigned int)len > todo) len = todo;
buf[0] = htonl(len);
if(sendln(sockd, (const char *)buf, len+sizeof(uint32_t))) { /* FIXME: need to handle limits */
logg("!Can't write to the socket.\n");
close(fd);
return 1;
}
todo -= len;
if(!todo) {
len = 0;
break;
}
}
close(fd);
if(len) {

Loading…
Cancel
Save