From 33bb563d147d69abf61a4adb3b8b5ecef67cf724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20=C3=89LIE?= Date: Sun, 24 Dec 2023 11:05:12 +0100 Subject: [PATCH] ovsqlite: Add a constant for max overview size Mention that SEARCHSPACE and MAX_OVDATA_SIZE are related. --- storage/ovsqlite/ovsqlite-server.c | 9 +++++++-- storage/ovsqlite/ovsqlite.c | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/storage/ovsqlite/ovsqlite-server.c b/storage/ovsqlite/ovsqlite-server.c index 791a9e55a..4cbe07cbc 100644 --- a/storage/ovsqlite/ovsqlite-server.c +++ b/storage/ovsqlite/ovsqlite-server.c @@ -43,6 +43,11 @@ # define OVSQLITE_DB_FILE "ovsqlite.db" +/* A single overview record must not exceed the client buffer size, so if + * MAX_OVDATA_SIZE is increased, SEARCHSPACE must also be increased in + * ovsqlite.c. */ +# define MAX_OVDATA_SIZE 100000 + # ifdef HAVE_ZLIB # define USE_DICTIONARY 1 @@ -1584,7 +1589,7 @@ do_search_group(client_t *client) overview = sqlite3_column_blob(stmt, 4); size = sqlite3_column_bytes(stmt, 4); - if (!overview || size > 100000) + if (!overview || size > MAX_OVDATA_SIZE) goto corrupted; overview_len = size; # ifdef HAVE_ZLIB @@ -1605,7 +1610,7 @@ do_search_group(client_t *client) inflation.avail_in = overview_len; raw_len = unpack_length(&inflation); - if (raw_len > 100000) + if (raw_len > MAX_OVDATA_SIZE) goto corrupted; if (raw_len > 0) { buffer_resize(flate, raw_len); diff --git a/storage/ovsqlite/ovsqlite.c b/storage/ovsqlite/ovsqlite.c index 7850d3143..789b64889 100644 --- a/storage/ovsqlite/ovsqlite.c +++ b/storage/ovsqlite/ovsqlite.c @@ -27,6 +27,9 @@ # include "../ovinterface.h" +/* A single overview record must not exceed the client buffer size, so if + * SEARCHSPACE is decreased, MAX_OVDATA_SIZE must also be decreased in + * ovsqlite-server.c. */ # define SEARCHSPACE 0x20000 typedef struct handle_t {