char portbuf[SIZ];
int is_virus = 0;
int clamhost;
- char *msgtext;
- size_t msglen;
+ StrBuf *msgtext;
+ CitContext *CCC;
/* Don't care if you're logged in. You can still spread viruses.
*/
*/
return(0);
}
+ CCC=CC;
+ CCC->sReadBuf = NewStrBuf();
+ CCC->sMigrateBuf = NewStrBuf();
+ CCC->sPos = NULL;
/* Command */
CtdlLogPrintf(CTDL_DEBUG, "Transmitting STREAM command\n");
sprintf(buf, "STREAM\r\n");
- sock_write(sock, buf, strlen(buf));
+ sock_write(&sock, buf, strlen(buf));
CtdlLogPrintf(CTDL_DEBUG, "Waiting for PORT number\n");
if (sock_getln(&sock, buf, sizeof buf) < 0) {
/* If the service isn't running, just pass the mail
* through. Potentially throwing away mails isn't good.
*/
+ FreeStrBuf(&CCC->sReadBuf);
+ FreeStrBuf(&CCC->sMigrateBuf);
return(0);
}
else {
/* Message */
- CC->redirect_buffer = malloc(SIZ);
- CC->redirect_len = 0;
- CC->redirect_alloc = SIZ;
+ CC->redirect_buffer = NewStrBufPlain(NULL, SIZ);
CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ALL, 0, 1, 0);
msgtext = CC->redirect_buffer;
- msglen = CC->redirect_len;
CC->redirect_buffer = NULL;
- CC->redirect_len = 0;
- CC->redirect_alloc = 0;
- sock_write(streamsock, msgtext, msglen);
- free(msgtext);
+ sock_write(&streamsock, SKEY(msgtext));
+ FreeStrBuf(&msgtext);
/* Close the streamsocket connection; this tells clamd
* that we're done.
*/
- close(streamsock);
+ if (streamsock != -1)
+ close(streamsock);
/* Response */
CtdlLogPrintf(CTDL_DEBUG, "Awaiting response\n");
}
bail: close(sock);
+ FreeStrBuf(&CCC->sReadBuf);
+ FreeStrBuf(&CCC->sMigrateBuf);
return(is_virus);
}