new file mode 100644
@@ -0,0 +1,282 @@
+From 85022ddd6ccce9675911c1f6c256fa7c5304de75 Mon Sep 17 00:00:00 2001
+From: Karthik Nayak <karthik.188@gmail.com>
+Date: Wed, 25 Mar 2026 10:30:32 +0100
+Subject: [PATCH] apply: reject binary patches greater than MAX_APPLY_SIZE
+
+In f1c0e3946e (apply: reject patches larger than ~1 GiB, 2022-10-25) we
+added a check to skip patches greater than ~1 GiB. This was because the
+apply code does not work well with large files. It uses 'int' and
+'unsigned long' interchangeably for storing the size of the patch. For
+large patches whose size is stored in an 'unsigned long' and then moved
+to an 'int', the value can wrap around and cause issues.
+
+Unfortunately the fix applied earlier does not work for binary files.
+As the size of a binary diff is different from the actual on disk size
+since binary diffs are compressed with zlib and encoded with base85.
+Binary diffs whose inflated size is very large will crash with an
+out-of-bounds read in `patch_delta()` when the truncated `delta_size`
+exceeds the real buffer length.
+
+Let's apply a similar fix by checking the final decoded length of a
+binary patch and fail if it is larger than MAX_APPLY_SIZE.
+
+Add a simple test with data consisting of zeros that when compressed and
+encoded is less than MAX_APPLY_SIZE.
+
+CVE: CVE-2026-114469
+Upstream-Status: Backport [https://github.com/git/git/commit/55c54fd375849d303ab71307fc8f79254877cc89]
+
+Backport Changes:
+- Fold the chunk encoder from [1] and the base85 test helper and
+ build registrations from [2] into this fix. Without these,
+ Git 2.53.0 test-tool fails with no tool named base85.
+- Retain the existing encode_85() interface and diff.c emission
+ path; their upstream refactor is not required by the tests.
+
+[1] https://github.com/git/git/commit/f0f7ab0b68e59a793aae837fddcefd138e932ad3
+[2] https://github.com/git/git/commit/15b2d49c4d7920efcbf4baa2fa85b3d0836062b9
+
+Reported-by: pwn2addr <p2addr@gmail.com>
+Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
+Signed-off-by: Ashishkumar Parmar <asparmar@cisco.com>
+---
+ Makefile | 1 +
+ apply.c | 13 +++++++++--
+ base85.c | 31 +++++++++++++++++++++++++++
+ base85.h | 10 +++++++++
+ t/helper/meson.build | 1 +
+ t/helper/test-base85.c | 44 ++++++++++++++++++++++++++++++++++++++
+ t/helper/test-tool.c | 1 +
+ t/helper/test-tool.h | 1 +
+ t/t4141-apply-too-large.sh | 19 ++++++++++++++++
+ 9 files changed, 119 insertions(+), 2 deletions(-)
+ create mode 100644 t/helper/test-base85.c
+
+diff --git a/Makefile b/Makefile
+index cd111e2b..ada0fba8 100644
+--- a/Makefile
++++ b/Makefile
+@@ -801,6 +801,7 @@ X =
+ PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
+
+ TEST_BUILTINS_OBJS += test-advise.o
++TEST_BUILTINS_OBJS += test-base85.o
+ TEST_BUILTINS_OBJS += test-bitmap.o
+ TEST_BUILTINS_OBJS += test-bloom.o
+ TEST_BUILTINS_OBJS += test-bundle-uri.o
+diff --git a/apply.c b/apply.c
+index 3de4aa4d..e04e81ba 100644
+--- a/apply.c
++++ b/apply.c
+@@ -1968,6 +1968,7 @@ static struct fragment *parse_binary_hunk(struct apply_state *state,
+ char *data = NULL;
+ int hunk_size = 0;
+ struct fragment *frag;
++ const char *error_msg = NULL;
+
+ llen = linelen(buffer, size);
+ used = llen;
+@@ -1985,6 +1986,11 @@ static struct fragment *parse_binary_hunk(struct apply_state *state,
+ else
+ return NULL;
+
++ if (origlen >= MAX_APPLY_SIZE) {
++ error_msg = _("patch too large");
++ goto corrupt;
++ }
++
+ state->linenr++;
+ buffer += llen;
+ size -= llen;
+@@ -2045,8 +2051,11 @@ static struct fragment *parse_binary_hunk(struct apply_state *state,
+ corrupt:
+ free(data);
+ *status_p = -1;
+- error(_("corrupt binary patch at line %d: %.*s"),
+- state->linenr-1, llen-1, buffer);
++ if (error_msg)
++ error("%s", error_msg);
++ else
++ error(_("corrupt binary patch at line %d: %.*s"),
++ state->linenr - 1, llen - 1, buffer);
+ return NULL;
+ }
+
+diff --git a/base85.c b/base85.c
+index 80e899a2..97fd0652 100644
+--- a/base85.c
++++ b/base85.c
+@@ -101,6 +101,37 @@ void encode_85(char *buf, const unsigned char *data, int bytes)
+ *buf = 0;
+ }
+
++/*
++ * Split the provided data into chunks of at most 52 bytes. Each chunk
++ * is base85-encoded into a line with the following format:
++ * - Byte 0: encodes the chunk size (1-52) as a letter: 'A'-'Z' for
++ * 1-26 bytes, 'a'-'z' for 27-52 bytes.
++ * - Bytes 1 onwards: base85-encoded data (up to 65 bytes).
++ * - Followed by a newline and NUL terminator.
++ * The output callback is called once per line.
++ */
++void chunk_and_encode85(const unsigned char *data, unsigned long len,
++ each_encoded_line_fn output, void *output_data)
++{
++ while (len) {
++ int line_len;
++ int bytes = (BASE85_CHUNK_SIZE < len) ? BASE85_CHUNK_SIZE : len;
++ char line[71];
++ len -= bytes;
++ if (bytes <= 26)
++ line[0] = bytes + 'A' - 1;
++ else
++ line[0] = bytes - 26 + 'a' - 1;
++ encode_85(line + 1, data, bytes);
++ data = data + bytes;
++
++ line_len = strlen(line);
++ line[line_len++] = '\n';
++ line[line_len] = '\0';
++ output(line, line_len, output_data);
++ }
++}
++
+ #ifdef DEBUG_85
+ int main(int ac, char **av)
+ {
+diff --git a/base85.h b/base85.h
+index c835086e..d3952aed 100644
+--- a/base85.h
++++ b/base85.h
+@@ -1,7 +1,17 @@
+ #ifndef BASE85_H
+ #define BASE85_H
+
++/*
++ * We pick 52, a multiple of 4 so there are no partial groups and it
++ * fits in the A-Za-z length prefix encoding.
++ */
++#define BASE85_CHUNK_SIZE 52
++
++typedef void each_encoded_line_fn(char *line, int len, void *cb_data);
++
+ int decode_85(char *dst, const char *line, int linelen);
+ void encode_85(char *buf, const unsigned char *data, int bytes);
++void chunk_and_encode85(const unsigned char *data, unsigned long len,
++ each_encoded_line_fn output, void *output_data);
+
+ #endif /* BASE85_H */
+diff --git a/t/helper/meson.build b/t/helper/meson.build
+index 0e38ca3a..eb821ef0 100644
+--- a/t/helper/meson.build
++++ b/t/helper/meson.build
+@@ -1,6 +1,7 @@
+ test_tool_sources = [
+ '../unit-tests/test-lib.c',
+ 'test-advise.c',
++ 'test-base85.c',
+ 'test-bitmap.c',
+ 'test-bloom.c',
+ 'test-bundle-uri.c',
+diff --git a/t/helper/test-base85.c b/t/helper/test-base85.c
+new file mode 100644
+index 00000000..98c591b4
+--- /dev/null
++++ b/t/helper/test-base85.c
+@@ -0,0 +1,44 @@
++#include "test-tool.h"
++#include "base85.h"
++
++#define MAX_INPUT_BUF BASE85_CHUNK_SIZE * 1024
++
++static const char *base85_usage = "test-tool base85 chunk-encode";
++
++static void print_binary_diff_line(char line[71], int len, void *output_data UNUSED)
++{
++ fwrite(line, 1, len, stdout);
++}
++
++static void base85_chunk(void)
++{
++ unsigned char *input = xmalloc(MAX_INPUT_BUF);
++
++ for (;;) {
++ ssize_t len = read_in_full(0, input, MAX_INPUT_BUF);
++ if (len < 0)
++ die_errno("read error");
++
++ chunk_and_encode85(input, len, print_binary_diff_line, NULL);
++ if (len < MAX_INPUT_BUF)
++ break;
++ }
++
++ putc('\n', stdout);
++ free(input);
++}
++
++int cmd__base85(int argc, const char **argv)
++{
++ if (argc != 2)
++ usage(base85_usage);
++
++ if (!strcmp(argv[1], "chunk-encode")) {
++ base85_chunk();
++ } else {
++ error("unknown subcommand: %s", argv[1]);
++ usage(base85_usage);
++ }
++
++ return 0;
++}
+diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c
+index feb5b6f4..aadfd4b7 100644
+--- a/t/helper/test-tool.c
++++ b/t/helper/test-tool.c
+@@ -11,6 +11,7 @@ static const char * const test_tool_usage[] = {
+
+ static struct test_cmd cmds[] = {
+ { "advise", cmd__advise_if_enabled },
++ { "base85", cmd__base85 },
+ { "bitmap", cmd__bitmap },
+ { "bloom", cmd__bloom },
+ { "bundle-uri", cmd__bundle_uri },
+diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h
+index 669c7bef..996bfa64 100644
+--- a/t/helper/test-tool.h
++++ b/t/helper/test-tool.h
+@@ -4,6 +4,7 @@
+ #include "git-compat-util.h"
+
+ int cmd__advise_if_enabled(int argc, const char **argv);
++int cmd__base85(int argc, const char **argv);
+ int cmd__bitmap(int argc, const char **argv);
+ int cmd__bloom(int argc, const char **argv);
+ int cmd__bundle_uri(int argc, const char **argv);
+diff --git a/t/t4141-apply-too-large.sh b/t/t4141-apply-too-large.sh
+index eac6f7e1..7e311a5f 100755
+--- a/t/t4141-apply-too-large.sh
++++ b/t/t4141-apply-too-large.sh
+@@ -19,4 +19,23 @@ test_expect_success EXPENSIVE 'git apply rejects patches that are too large' '
+ grep "patch too large" err
+ '
+
++test_expect_success EXPENSIVE 'git apply rejects binary patches that are too large' '
++ sz=$((1024 * 1024 * 2048)) &&
++ test-tool genzeros $sz | test-tool zlib deflate | test-tool base85 chunk-encode >payload &&
++ {
++ # Although the patch requires the correct blob ID, blob ID validation
++ # happens after the inflated content size check, so use $EMPTY_BLOB as
++ # a filler.
++ cat <<-EOF &&
++ diff --git a/file b/file
++ new file mode 100644
++ index $ZERO_OID..$EMPTY_BLOB
++ GIT binary patch
++ literal $sz
++ EOF
++ cat payload
++ } | test_must_fail git apply 2>err &&
++ grep "patch too large" err
++'
++
+ test_done
new file mode 100644
@@ -0,0 +1,118 @@
+From 89a65caa611bb2ca3e517447183d96719d06982a Mon Sep 17 00:00:00 2001
+From: Karthik Nayak <karthik.188@gmail.com>
+Date: Wed, 25 Mar 2026 10:30:33 +0100
+Subject: [PATCH] apply: add tests mismatch in binary patch size
+
+The previous commit added a check to ensure that the mentioned literal
+length of a given binary patch does not exceed 'MAX_APPLY_SIZE'.
+However, this doesn't mean an attacker cannot modify the literal patch
+size mentioned in the patch headers.
+
+Fortunately, we're already safeguarded against such attacks. Applying a
+binary patch includes the following steps:
+
+ 1. Checking that the file size doesn't exceed 'MAX_APPLY_SIZE'.
+ 2. Base85 decoding the content (reduces the size of the patch by 4/5).
+ 3. Zlib inflating the decoded content (possibly increases the size).
+
+As we already check the file size in step 1 and step 2 will only reduce
+the given size, there is no chance that the content would exceed
+'MAX_APPLY_SIZE' at step 2.
+
+That means the only chance is that step 3 could inflate the size beyond
+'MAX_APPLY_SIZE'. While this is indeed possible, inflation is done using
+the `inflate_it()` command, which takes in the expected size. The
+expected size is the literal size mentioned in the patch header. If the
+inflated content doesn't match this provided size, we error out. So
+we're safe here too.
+
+Let's add two tests to capture these behaviors. First one to add a large
+binary patch which fails due to large file size. Second a binary patch
+with mismatched size, which fails during inflation.
+
+The second test also exposes two memory leaks. One where the initialized
+`struct fragment *` is not freed in such a scenario. Fix it, by free'ing
+it before we exit the function. The second where a large binary file is
+read but because it is too large, we throw an error. Here, we free the
+buffer the file is read into.
+
+CVE: CVE-2026-114469
+Upstream-Status: Backport [https://github.com/git/git/commit/dee1bb2a9fc75c3a1f7f1c6aaf86ff2c038bd436]
+
+Reported-by: pwn2addr <p2addr@gmail.com>
+Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
+Signed-off-by: Ashishkumar Parmar <asparmar@cisco.com>
+---
+ apply.c | 10 +++++++---
+ t/t4141-apply-too-large.sh | 31 +++++++++++++++++++++++++++++++
+ 2 files changed, 38 insertions(+), 3 deletions(-)
+
+diff --git a/apply.c b/apply.c
+index e04e81ba..704b5a9e 100644
+--- a/apply.c
++++ b/apply.c
+@@ -2038,8 +2038,10 @@ static struct fragment *parse_binary_hunk(struct apply_state *state,
+ CALLOC_ARRAY(frag, 1);
+ frag->patch = inflate_it(data, hunk_size, origlen);
+ frag->free_patch = 1;
+- if (!frag->patch)
++ if (!frag->patch) {
++ free(frag);
+ goto corrupt;
++ }
+ free(data);
+ frag->size = origlen;
+ *buf_p = buffer;
+@@ -4814,8 +4816,10 @@ static int apply_patch(struct apply_state *state,
+ int flush_attributes = 0;
+
+ state->patch_input_file = filename;
+- if (read_patch_file(&buf, fd) < 0)
+- return -128;
++ if (read_patch_file(&buf, fd) < 0) {
++ res = -128;
++ goto end;
++ }
+ offset = 0;
+ while (offset < buf.len) {
+ struct patch *patch;
+diff --git a/t/t4141-apply-too-large.sh b/t/t4141-apply-too-large.sh
+index 7e311a5f..1cd5792b 100755
+--- a/t/t4141-apply-too-large.sh
++++ b/t/t4141-apply-too-large.sh
+@@ -38,4 +38,35 @@ test_expect_success EXPENSIVE 'git apply rejects binary patches that are too lar
+ grep "patch too large" err
+ '
+
++test_expect_success EXPENSIVE 'git apply rejects large binary patches with incorrect size' '
++ sz=$((1024 * 1024 * 1023)) &&
++ test-tool genrandom foo $sz | test-tool zlib deflate | test-tool base85 chunk-encode >payload &&
++ {
++ cat <<-EOF &&
++ diff --git a/file b/file
++ new file mode 100644
++ index $ZERO_OID..$EMPTY_BLOB
++ GIT binary patch
++ literal 10
++ EOF
++ cat payload
++ } | test_must_fail git apply 2>err &&
++ grep "patch too large" err
++'
++
++test_expect_success 'git apply rejects binary patches with incorrect size' '
++ test-tool genrandom foo 100 | test-tool zlib deflate | test-tool base85 chunk-encode >payload &&
++ {
++ cat <<-EOF &&
++ diff --git a/file b/file
++ new file mode 100644
++ index $ZERO_OID..$EMPTY_BLOB
++ GIT binary patch
++ literal 10
++ EOF
++ cat payload
++ } | test_must_fail git apply 2>err &&
++ grep "corrupt binary patch" err
++'
++
+ test_done
@@ -22,6 +22,8 @@ SRC_URI = "${KERNELORG_MIRROR}/software/scm/git/git-${PV}.tar.gz;name=tarball \
file://CVE-2026-111760_p3.patch \
file://CVE-2026-111760_p4.patch \
file://CVE-2026-114467.patch \
+ file://CVE-2026-114469_p1.patch \
+ file://CVE-2026-114469_p2.patch \
"
SRC_URI:append:class-nativesdk = " \