mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-16 00:03:45 +00:00
1. Fixed bug where the last result data length could include the NULL terminator if the input string length was too long.
2. Updated DB calls, to Get/Put will truncate the NULL terminator if it is specified in the key name 3. Updated COMPACT, so keynames will be fixed if it contains a NULL terminator
This commit is contained in:
@@ -4643,6 +4643,7 @@ struct parser_result* ILibParseString(char* buffer, int offset, int length, cons
|
|||||||
// Iterate through the string to find delimiters
|
// Iterate through the string to find delimiters
|
||||||
//
|
//
|
||||||
Token = buffer + offset;
|
Token = buffer + offset;
|
||||||
|
if (Token[length - 1] == 0) { length -= 1; }
|
||||||
for(i = offset; i < length; ++i)
|
for(i = offset; i < length; ++i)
|
||||||
{
|
{
|
||||||
if (ILibIsDelimiter(buffer, i, length, Delimiter, DelimiterLength))
|
if (ILibIsDelimiter(buffer, i, length, Delimiter, DelimiterLength))
|
||||||
|
|||||||
@@ -295,6 +295,7 @@ __EXPORT_TYPE int ILibSimpleDataStore_PutEx(ILibSimpleDataStore dataStore, char*
|
|||||||
ILibSimpleDataStore_TableEntry *entry;
|
ILibSimpleDataStore_TableEntry *entry;
|
||||||
|
|
||||||
if (root == NULL) return 0;
|
if (root == NULL) return 0;
|
||||||
|
if (keyLen > 1 && key[keyLen - 1] == 0) { keyLen -= 1; }
|
||||||
entry = (ILibSimpleDataStore_TableEntry*)ILibHashtable_Get(root->keyTable, NULL, key, keyLen);
|
entry = (ILibSimpleDataStore_TableEntry*)ILibHashtable_Get(root->keyTable, NULL, key, keyLen);
|
||||||
ILibSimpleDataStore_SHA384(value, valueLen, hash); // Hash the value
|
ILibSimpleDataStore_SHA384(value, valueLen, hash); // Hash the value
|
||||||
|
|
||||||
@@ -322,6 +323,7 @@ __EXPORT_TYPE int ILibSimpleDataStore_GetEx(ILibSimpleDataStore dataStore, char*
|
|||||||
ILibSimpleDataStore_TableEntry *entry;
|
ILibSimpleDataStore_TableEntry *entry;
|
||||||
|
|
||||||
if (root == NULL) return 0;
|
if (root == NULL) return 0;
|
||||||
|
if (keyLen > 1 && key[keyLen - 1] == 0) { keyLen -= 1; }
|
||||||
entry = (ILibSimpleDataStore_TableEntry*)ILibHashtable_Get(root->keyTable, NULL, key, keyLen);
|
entry = (ILibSimpleDataStore_TableEntry*)ILibHashtable_Get(root->keyTable, NULL, key, keyLen);
|
||||||
|
|
||||||
if (entry == NULL) return 0; // If there is no in-memory entry for this key, return zero now.
|
if (entry == NULL) return 0; // If there is no in-memory entry for this key, return zero now.
|
||||||
@@ -393,6 +395,13 @@ void ILibSimpleDataStore_Compact_EnumerateSink(ILibHashtable sender, void *Key1,
|
|||||||
if (root == NULL) return;
|
if (root == NULL) return;
|
||||||
if (root->error != 0) return; // There was an error, ABORT!
|
if (root->error != 0) return; // There was an error, ABORT!
|
||||||
|
|
||||||
|
if (Key2Len > 1)
|
||||||
|
{
|
||||||
|
if (Key2[Key2Len - 1] == 0)
|
||||||
|
{
|
||||||
|
Key2Len -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
offset = ILibSimpleDataStore_WriteRecord(compacted, Key2, Key2Len, NULL, entry->valueLength, entry->valueHash);
|
offset = ILibSimpleDataStore_WriteRecord(compacted, Key2, Key2Len, NULL, entry->valueLength, entry->valueHash);
|
||||||
while (bytesLeft > 0)
|
while (bytesLeft > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user