git » nmdb » commit ffc6369

Fix the return value when the get packet has broken sizes.

author Alberto Bertogli
2007-09-01 23:38:56 UTC
committer Alberto Bertogli
2007-09-01 23:38:56 UTC
parent b010ed3d5407dda8bfdd30838e2d941c5efbd4ae

Fix the return value when the get packet has broken sizes.

Signed-off-by: Alberto Bertogli <albertito@gmail.com>

libnmdb/libnmdb.c +3 -1

diff --git a/libnmdb/libnmdb.c b/libnmdb/libnmdb.c
index 5409b70..eb2a1d7 100644
--- a/libnmdb/libnmdb.c
+++ b/libnmdb/libnmdb.c
@@ -309,7 +309,9 @@ static ssize_t do_get(nmdb_t *db,
 	rv = * (uint32_t *) p;
 	rv = ntohl(rv);
 	if (rv > (psize - 4) || rv > vsize) {
-		rv = 0;
+		/* the value is too big for the packet size, or it is too big
+		 * to fit in the buffer we were given */
+		rv = -2;
 		goto exit;
 	}
 	memcpy(val, p + 4, rv);