Skip to content

Commit 0f81be8

Browse files
committed
fix: parse text settings as decimal integers
Change dbutils_settings_get_value to parse text-backed integer settings with base 10 instead of base 0. This avoids surprising octal handling for values with leading zeroes while preserving the documented decimal byte values used by payload_max_chunk_size. Add a unit assertion that '010' reads back as 10.
1 parent 1cf4a4d commit 0f81be8

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/dbutils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ int dbutils_settings_get_value (cloudsync_context *data, const char *key, char *
147147
int type = database_column_type(vm, 0);
148148
if (type == DBTYPE_TEXT) {
149149
const char *value = database_column_text(vm, 0);
150-
*intvalue = value ? strtoll(value, NULL, 0) : 0;
150+
*intvalue = value ? strtoll(value, NULL, 10) : 0;
151151
} else {
152152
*intvalue = database_column_int(vm, 0);
153153
}

test/unit.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,6 +1901,11 @@ bool do_test_dbutils (void) {
19011901
rc = dbutils_settings_get_value(data, "key2", buffer, &blen, NULL);
19021902
if (rc != SQLITE_OK) goto finalize;
19031903
if (buffer[0] != 0) goto finalize;
1904+
1905+
dbutils_settings_set_key_value(data, "decimal_key", "010");
1906+
int64_t intvalue = 0;
1907+
rc = dbutils_settings_get_value(data, "decimal_key", NULL, NULL, &intvalue);
1908+
if (rc != SQLITE_OK || intvalue != 10) goto finalize;
19041909

19051910
// test table settings
19061911
rc = dbutils_table_settings_set_key_value(data, NULL, NULL, NULL, NULL);

0 commit comments

Comments
 (0)