summaryrefslogtreecommitdiffstats
path: root/reftable
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-12-23 18:32:08 +0100
committerJunio C Hamano <gitster@pobox.com>2024-12-23 18:32:08 +0100
commitf7c607fac3dd906c46d0d86ff174215698912316 (patch)
tree407e5328ed8704476b3f593b60d8bcdea55cd48c /reftable
parentMerge branch 'ps/ci-gitlab-update' (diff)
parentreftable/writer: ensure valid range for log's update_index (diff)
downloadgit-f7c607fac3dd906c46d0d86ff174215698912316.tar.xz
git-f7c607fac3dd906c46d0d86ff174215698912316.zip
Merge branch 'kn/reftable-writer-log-write-verify'
Reftable backend adds check for upper limit of log's update_index. * kn/reftable-writer-log-write-verify: reftable/writer: ensure valid range for log's update_index
Diffstat (limited to 'reftable')
-rw-r--r--reftable/writer.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/reftable/writer.c b/reftable/writer.c
index 9efeab13e1..624e90fb53 100644
--- a/reftable/writer.c
+++ b/reftable/writer.c
@@ -425,6 +425,18 @@ int reftable_writer_add_log(struct reftable_writer *w,
if (log->value_type == REFTABLE_LOG_DELETION)
return reftable_writer_add_log_verbatim(w, log);
+ /*
+ * Verify only the upper limit of the update_index. Each reflog entry
+ * is tied to a specific update_index. Entries in the reflog can be
+ * replaced by adding a new entry with the same update_index,
+ * effectively canceling the old one.
+ *
+ * Consequently, reflog updates may include update_index values lower
+ * than the writer's min_update_index.
+ */
+ if (log->update_index > w->max_update_index)
+ return REFTABLE_API_ERROR;
+
if (!log->refname)
return REFTABLE_API_ERROR;