aboutsummaryrefslogtreecommitdiffhomepage
path: root/database.cc
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2009-10-24 22:10:03 -0700
committerGravatar Carl Worth <cworth@cworth.org>2009-10-24 22:10:03 -0700
commit0bc73af96c48952cba29116f0c99e8ba3f9e7ef6 (patch)
tree68a2d34a076406404ed5574e39944774e6ab3464 /database.cc
parentf281f4b677e56242c18628683dcd4533906f7551 (diff)
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.
Diffstat (limited to 'database.cc')
-rw-r--r--database.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/database.cc b/database.cc
index c470cc34..3d967270 100644
--- a/database.cc
+++ b/database.cc
@@ -542,11 +542,12 @@ find_timestamp_document (notmuch_database_t *notmuch, const char *db_key,
static char *
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);
- } else {
+ else
return strdup (key);
- }
}
notmuch_status_t