aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-06-08 12:52:39 +0200
committerMattias Andrée <maandree@operamail.com>2014-06-08 12:52:45 +0200
commit195eb255e53c8327a743ef89c616c6532d364de2 (patch)
treecf23930ac84b900ce540436a8d67f9679f08a19a
parentmds-echo: include message id + do not require respawn status (diff)
downloadmds-195eb255e53c8327a743ef89c616c6532d364de2.tar.gz
mds-195eb255e53c8327a743ef89c616c6532d364de2.tar.bz2
mds-195eb255e53c8327a743ef89c616c6532d364de2.tar.xz
m + fix: include header value in interception conditions
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--doc/messages2
-rw-r--r--src/mds-echo.c6
-rw-r--r--src/mds-server/interceptors.c5
3 files changed, 9 insertions, 4 deletions
diff --git a/doc/messages b/doc/messages
index 8dd583c..314d17a 100644
--- a/doc/messages
+++ b/doc/messages
@@ -57,7 +57,7 @@ the type of message this is being sent. This technique
is also used to intercept message or receive message
as part of a service that a server provides. Servers
that implement the ability to connect from another
-computer are encouraged to reject this time of message
+computer are encouraged to reject this type of message
if it could be used for spying. To tell the server
that you want to intercept a type of message the client
sends a message with the header and value
diff --git a/src/mds-echo.c b/src/mds-echo.c
index 8d1fae0..c9087c5 100644
--- a/src/mds-echo.c
+++ b/src/mds-echo.c
@@ -97,12 +97,12 @@ int __attribute__((const)) preinitialise_server(void)
*/
int initialise_server(void)
{
- const char* message =
+ const char* const message =
"Command: intercept\n"
"Message ID: 0\n"
- "Length: 13\n"
+ "Length: 14\n"
"\n"
- "Command: echo";
+ "Command: echo\n";
if (full_send(message, strlen(message)))
return 1;
diff --git a/src/mds-server/interceptors.c b/src/mds-server/interceptors.c
index 38442bd..552d7a1 100644
--- a/src/mds-server/interceptors.c
+++ b/src/mds-server/interceptors.c
@@ -77,6 +77,7 @@ void add_intercept_condition(client_t* client, char* condition, int64_t priority
interception_condition_t* conds = client->interception_conditions;
ssize_t nonmodifying = -1;
char* header = condition;
+ char* colon = NULL;
char* value;
size_t hash;
size_t i;
@@ -85,11 +86,15 @@ void add_intercept_condition(client_t* client, char* condition, int64_t priority
if ((value = strchr(header, ':')) != NULL)
{
*value = '\0'; /* NUL-terminate header. */
+ colon = value; /* End of header. */
value += 2; /* Skip over delimiter. */
}
/* Calcuate header hash (comparison optimisation) */
hash = string_hash(header);
+ /* Undo header–value splitting. */
+ if (colon != NULL)
+ *colon = ':';
/* Remove of update condition of already registered,
also look for non-modifying condition to swap position