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
This commit is contained in:
Junio C Hamano
2024-12-23 09:32:08 -08:00
3 changed files with 63 additions and 4 deletions

View File

@@ -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;