mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 20:38:08 +01:00
Fix timestamp generation to avoid overflowing the term limit
The previous code was only correct as long as the timestamp prefix was only a single character. But with the recent change to a multi-character prefix, this broke. So fix it now.
This commit is contained in:
parent
f281f4b677
commit
0bc73af96c
1 changed files with 4 additions and 3 deletions
|
@ -542,12 +542,13 @@ find_timestamp_document (notmuch_database_t *notmuch, const char *db_key,
|
||||||
static char *
|
static char *
|
||||||
timestamp_db_key (const char *key)
|
timestamp_db_key (const char *key)
|
||||||
{
|
{
|
||||||
if (strlen (key) + 1 > NOTMUCH_TERM_MAX) {
|
int term_len = strlen (_find_prefix ("timestamp")) + strlen (key);
|
||||||
|
|
||||||
|
if (term_len > NOTMUCH_TERM_MAX)
|
||||||
return notmuch_sha1_of_string (key);
|
return notmuch_sha1_of_string (key);
|
||||||
} else {
|
else
|
||||||
return strdup (key);
|
return strdup (key);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
notmuch_status_t
|
notmuch_status_t
|
||||||
notmuch_database_set_timestamp (notmuch_database_t *notmuch,
|
notmuch_database_set_timestamp (notmuch_database_t *notmuch,
|
||||||
|
|
Loading…
Reference in a new issue