From 328629445c71e6c17074f6e9e0e3ef585b58f167 Mon Sep 17 00:00:00 2001 From: dormando Date: Tue, 4 Jul 2017 00:32:39 -0700 Subject: [PATCH] sanity check --- items.c | 2 ++ memcached.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/items.c b/items.c index 637e5e745..83a2ea37d 100644 --- a/items.c +++ b/items.c @@ -368,6 +368,8 @@ void item_free(item *it) { bool item_size_ok(const size_t nkey, const int flags, const int nbytes) { char prefix[40]; uint8_t nsuffix; + if (nbytes < 2) + return false; size_t ntotal = item_make_header(nkey + 1, flags, nbytes, prefix, &nsuffix); diff --git a/memcached.c b/memcached.c index 0f0335795..a89df965d 100644 --- a/memcached.c +++ b/memcached.c @@ -4967,7 +4967,7 @@ static void drive_machine(conn *c) { case conn_swallow: /* we are reading sbytes and throwing them away */ - if (c->sbytes == 0) { + if (c->sbytes <= 0) { conn_set_state(c, conn_new_cmd); break; }