summaryrefslogtreecommitdiffstats
path: root/src/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/core.c b/src/core.c
index 8b2832a..bb76df0 100644
--- a/src/core.c
+++ b/src/core.c
@@ -160,6 +160,7 @@ enum og_agent_state {
static int og_agent_state_recv_hdr_rest(struct og_client *cli)
{
+ uint32_t seq;
char *ptr;
ptr = strstr(cli->buf, "\r\n\r\n");
@@ -176,6 +177,20 @@ static int og_agent_state_recv_hdr_rest(struct og_client *cli)
cli->msg_len += cli->content_length;
}
+ ptr = strstr(cli->buf, "X-Sequence: ");
+ if (ptr) {
+ if (sscanf(ptr, "X-Sequence: %i[^\r\n]", &seq) != 1) {
+ syslog(LOG_ERR, "Invalid sequence value from client %s. Payload:\n%s",
+ inet_ntoa(cli->addr.sin_addr), cli->buf);
+ return -1;
+ }
+ if (cli->seq != 0 && cli->seq != seq) {
+ syslog(LOG_ERR, "Unexpected sequence %u from client %s, expecting %u.",
+ seq, inet_ntoa(cli->addr.sin_addr), cli->seq);
+ return -1;
+ }
+ }
+
return 1;
}