e2e2236f4d
Note to -stable ports maintainers: This should probably be put into -stable since the ClamAV people do not provide virus data to outdated scan engines. ok simon
46 lines
1.4 KiB
Plaintext
46 lines
1.4 KiB
Plaintext
$OpenBSD: patch-clamd_session_c,v 1.4 2007/08/25 10:08:28 mbalmer Exp $
|
|
--- clamd/session.c.orig Sat Mar 31 20:57:47 2007
|
|
+++ clamd/session.c Sat Aug 25 09:35:06 2007
|
|
@@ -59,8 +59,10 @@ int command(int desc, const struct cl_engine *engine,
|
|
{
|
|
char buff[1025];
|
|
int bread, opt;
|
|
+ struct msghdr msg;
|
|
+ struct cmsghdr *cmsg;
|
|
+ unsigned char buf[CMSG_SPACE(sizeof(int))];
|
|
|
|
-
|
|
bread = readsock(desc, buff, sizeof(buff)-1, '\n', timeout, 0, 1);
|
|
if(bread == -2) /* timeout */
|
|
return -2;
|
|
@@ -155,6 +157,29 @@ int command(int desc, const struct cl_engine *engine,
|
|
if(cfgopt(copt, "ExitOnOOM")->enabled)
|
|
return COMMAND_SHUTDOWN;
|
|
|
|
+ } else if(!strncmp(buff, CMD14, strlen(CMD14))) { /* FILDES */
|
|
+ memset(&msg, 0, sizeof(msg));
|
|
+ msg.msg_control = buf;
|
|
+ msg.msg_controllen = sizeof(buf);
|
|
+
|
|
+ if (recvmsg(desc, &msg, 0) == -1) {
|
|
+ logg("recvmsg failed!");
|
|
+ return -1;
|
|
+ }
|
|
+ if ((msg.msg_flags & MSG_TRUNC) || (msg.msg_flags & MSG_CTRUNC)) {
|
|
+ logg("control message truncated");
|
|
+ return -1;
|
|
+ }
|
|
+ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL;
|
|
+ cmsg = CMSG_NXTHDR(&msg, cmsg)) {
|
|
+ if (cmsg->cmsg_len == CMSG_LEN(sizeof(int)) &&
|
|
+ cmsg->cmsg_level == SOL_SOCKET &&
|
|
+ cmsg->cmsg_type == SCM_RIGHTS) {
|
|
+ int fd = *(int *)CMSG_DATA(cmsg);
|
|
+ scanfd(fd, NULL, engine, limits, options, copt, desc);
|
|
+ close(fd);
|
|
+ }
|
|
+ }
|
|
} else {
|
|
mdprintf(desc, "UNKNOWN COMMAND\n");
|
|
}
|