aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-08-25 15:34:00 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-08-25 15:34:00 +0400
commitac9d66b9a80f49235b21de577764c5457544cc66 (patch)
tree89aa5ec5b7a4009ba7b09bb2f05934d55e3b95c8 /src
parentab8f97db48ceefef5fdf47ea8a5954da635ffa31 (diff)
downloadrspamd-ac9d66b9a80f49235b21de577764c5457544cc66.tar.gz
rspamd-ac9d66b9a80f49235b21de577764c5457544cc66.zip
* Store sockaddr in large enough buffer
Diffstat (limited to 'src')
-rw-r--r--src/fuzzy_storage.c9
-rw-r--r--src/fuzzy_storage.h4
2 files changed, 7 insertions, 6 deletions
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index e9cbfa64d..ac0853303 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -305,12 +305,12 @@ process_delete_command (struct fuzzy_cmd *cmd)
#define CMD_PROCESS(x) \
do { \
if (process_##x##_command (&session->cmd)) { \
- if (sendto (session->fd, "OK" CRLF, sizeof ("OK" CRLF) - 1, 0, &session->sa, session->salen) == -1) { \
+ if (sendto (session->fd, "OK" CRLF, sizeof ("OK" CRLF) - 1, 0, (struct sockaddr *)&session->sa, session->salen) == -1) { \
msg_err ("process_fuzzy_command: error while writing reply: %s", strerror (errno)); \
} \
} \
else { \
- if (sendto (session->fd, "ERR" CRLF, sizeof ("ERR" CRLF) - 1, 0, &session->sa, session->salen) == -1) { \
+ if (sendto (session->fd, "ERR" CRLF, sizeof ("ERR" CRLF) - 1, 0, (struct sockaddr *)&session->sa, session->salen) == -1) { \
msg_err ("process_fuzzy_command: error while writing reply: %s", strerror (errno)); \
} \
} \
@@ -330,7 +330,7 @@ process_fuzzy_command (struct fuzzy_session *session)
CMD_PROCESS(delete);
break;
default:
- if (sendto (session->fd, "ERR" CRLF, sizeof ("ERR" CRLF) - 1, 0, &session->sa, session->salen) == -1) {
+ if (sendto (session->fd, "ERR" CRLF, sizeof ("ERR" CRLF) - 1, 0, (struct sockaddr *)&session->sa, session->salen) == -1) {
msg_err ("process_fuzzy_command: error while writing reply: %s", strerror (errno));
}
break;
@@ -354,10 +354,11 @@ accept_fuzzy_socket (int fd, short what, void *arg)
session.worker = worker;
session.fd = fd;
session.pos = (u_char *)&session.cmd;
+ session.salen = sizeof (session.sa);
/* Got some data */
if (what == EV_READ) {
- if ((r = recvfrom (fd, session.pos, sizeof (struct fuzzy_cmd), MSG_WAITALL, &session.sa, &session.salen)) == -1) {
+ if ((r = recvfrom (fd, session.pos, sizeof (struct fuzzy_cmd), MSG_WAITALL, (struct sockaddr *)&session.sa, &session.salen)) == -1) {
msg_err ("fuzzy_io_callback: got error while reading from socket: %d, %s", errno, strerror (errno));
return;
}
diff --git a/src/fuzzy_storage.h b/src/fuzzy_storage.h
index b03acfacb..1630171e4 100644
--- a/src/fuzzy_storage.h
+++ b/src/fuzzy_storage.h
@@ -21,8 +21,8 @@ struct fuzzy_session {
struct fuzzy_cmd cmd;
int fd;
u_char *pos;
- int salen;
- struct sockaddr sa;
+ socklen_t salen;
+ struct sockaddr_storage sa;
};
void start_fuzzy_storage (struct rspamd_worker *worker);