Skip to content

Commit

Permalink
ovsqlite: Add a constant for max overview size
Browse files Browse the repository at this point in the history
Mention that SEARCHSPACE and MAX_OVDATA_SIZE are related.
  • Loading branch information
Julien-Elie committed Dec 24, 2023
1 parent 1d5578c commit 33bb563
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 7 additions & 2 deletions storage/ovsqlite/ovsqlite-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions storage/ovsqlite/ovsqlite.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 33bb563

Please sign in to comment.