Permalink
Browse files

Applying patch so that UDP requests cannot cause the server to spin o…

…ut of control

Patch from Upstream Memcached - memcached/memcached@954f6dd

Don't permanently close UDP listeners on error
Also, don't inflate rbytes as we can only ever process one UDP packet at a
time.

Patch by pi3orama. Fixed by Dormando to use the correct state and actually
work.

I'm not fully convinced of the rbytes bit. We must ensure that a UDP packet
with multiple commands in it has all of its commands processed before we can
possibly call recvfrom again.
  • Loading branch information...
1 parent 23b6c0e commit 40fcc8a47b45d2092bd1ef7466cb0de622db0215 Ian Pye committed with dknecht Jan 4, 2013
Showing with 5 additions and 1 deletion.
  1. +4 −0 src/mc_connection.c
  2. +1 −1 src/mc_core.c
View
@@ -312,6 +312,10 @@ conn_cleanup(struct conn *c)
if (c->write_and_free != NULL) {
mc_free(c->write_and_free);
}
+
+ if (c->udp) {
+ conn_set_state(c, CONN_READ);
+ }
}
void
View
@@ -147,7 +147,7 @@ core_read_udp(struct conn *c)
res -= 8;
memmove(c->rbuf, c->rbuf + 8, res);
- c->rbytes += res;
+ c->rbytes = res;
c->rcurr = c->rbuf;
return READ_DATA_RECEIVED;

0 comments on commit 40fcc8a

Please sign in to comment.