)]}'
{
  "commit": "f11f0a5a2db955f68776ea95aec42df7fcb8ce1b",
  "tree": "789f88c73917bbd8b830b4b53884cf5f3b65947f",
  "parents": [
    "bc67b4ab5f8bc268ecd2d9bb7dc1b7bf26884a8e"
  ],
  "author": {
    "name": "Karthik Nayak",
    "email": "karthik.188@gmail.com",
    "time": "Mon Jan 27 10:44:08 2025 +0100"
  },
  "committer": {
    "name": "Junio C Hamano",
    "email": "gitster@pobox.com",
    "time": "Mon Jan 27 08:21:41 2025 -0800"
  },
  "message": "refs/reftable: fix uninitialized memory access of `max_index`\n\nWhen migrating reflogs between reference backends, maintaining the\noriginal order of the reflog entries is crucial. To achieve this, an\n`index` field is stored within the `ref_update` struct that encodes the\nrelative order of reflog entries. This field is used by the reftable\nbackend as update index for the respective reflog entries to maintain\nthat ordering.\n\nThese update indices must be respected when writing table headers, which\nencode the minimum and maximum update index of contained records in the\nheader and footer. This logic was added in commit bc67b4ab5f (reftable:\nwrite correct max_update_index to header, 2025-01-15), which started to\nuse `reftable_writer_set_limits()` to propagate the mininum and maximum\nupdate index of all records contained in a ref transaction.\n\nHowever, we only set the maximum update index for the first transaction\nargument, even though there can be multiple such arguments. This is the\ncase when we write to multiple stacks in a single transaction, e.g. when\nupdating references in two different worktrees at once. Consequently,\nthe update index for all but the first argument remain uninitialized,\nwhich may cause undefined behaviour.\n\nFix this by moving the assignment of the maximum update index in\n`reftable_be_transaction_finish()` inside the loop, which ensures that\nall elements of the array are correctly initialized.\n\nFurthermore, initialize the `max_index` field to 0 when queueing a new\ntransaction argument. This is not strictly necessary, as all elements of\n`write_transaction_table_arg.max_index` are now assigned correctly.\nHowever, this initialization is added for consistency and to safeguard\nagainst potential future changes that might inadvertently introduce\nuninitialized memory access.\n\nReported-by: Johannes Schindelin \u003cJohannes.Schindelin@gmx.de\u003e\nSigned-off-by: Karthik Nayak \u003ckarthik.188@gmail.com\u003e\nSigned-off-by: Patrick Steinhardt \u003cps@pks.im\u003e\nSigned-off-by: Junio C Hamano \u003cgitster@pobox.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "68db2baa8f15c44453656661f5295dbc0596b563",
      "old_mode": 33188,
      "old_path": "refs/reftable-backend.c",
      "new_id": "bb658826fe60a73707896e374268bd45c3b17cce",
      "new_mode": 33188,
      "new_path": "refs/reftable-backend.c"
    }
  ]
}
