summaryrefslogtreecommitdiff
path: root/memcached.c
diff options
context:
space:
mode:
authortom <tom@localhost.com>2021-01-29 12:14:33 +0800
committerdormando <dormando@rydia.net>2021-06-07 22:33:36 -0700
commit2f8add8838553db423acc2d526e89bb917c21814 (patch)
treed4748301c99fbe741f1bc8170f33131f2521ecf0 /memcached.c
parent2a8b96105857dee237889f6a9e02d42352874e02 (diff)
downloadmemcached-2f8add8838553db423acc2d526e89bb917c21814.tar.gz
The total number of UDP datagrams required for the message is calculated incorrectly.
UDP_MAX_PAYLOAD_SIZE actually contains the length of the private UDP header, but resp->tosend only contains the length of the data part. The number of required UDP packets calculated by the original code will be less than the actual need. E.g: 1000000/1400 = 714.2 ceil 715 1000000/1392 = 718.3 ceil 719 Actually 719 datagrams are needed, and 715 is wrong. Signed-off-by: AK Deng <ttttabcd@protonmail.com>
Diffstat (limited to 'memcached.c')
-rw-r--r--memcached.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/memcached.c b/memcached.c
index f41a89d..54369cd 100644
--- a/memcached.c
+++ b/memcached.c
@@ -2635,8 +2635,8 @@ static void build_udp_header(unsigned char *hdr, mc_resp *resp) {
// header, so "tosend" must be static.
if (!resp->udp_total) {
uint32_t total;
- total = resp->tosend / UDP_MAX_PAYLOAD_SIZE;
- if (resp->tosend % UDP_MAX_PAYLOAD_SIZE)
+ total = resp->tosend / UDP_DATA_SIZE;
+ if (resp->tosend % UDP_DATA_SIZE)
total++;
// The spec doesn't really say what we should do here. It's _probably_
// better to bail out?