|
| 1 | +From e692412cf74604829a21a7a23857a772d2197788 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Sudipta Pandit <sudpandit@microsoft.com> |
| 3 | +Date: Fri, 7 Feb 2025 01:57:06 +0530 |
| 4 | +Subject: [PATCH] Backport fix for CVE-2025-0840 |
| 5 | + |
| 6 | +Reference: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=baac6c221e9d69335bf41366a1c7d87d8ab2f893 |
| 7 | + |
| 8 | +--- |
| 9 | + binutils/objdump.c | 10 ++++++---- |
| 10 | + 1 file changed, 6 insertions(+), 4 deletions(-) |
| 11 | + |
| 12 | +diff --git a/binutils/objdump.c b/binutils/objdump.c |
| 13 | +index a35982ea..2efbf4b0 100644 |
| 14 | +--- a/binutils/objdump.c |
| 15 | ++++ b/binutils/objdump.c |
| 16 | +@@ -116,7 +116,8 @@ static bool disassemble_all; /* -D */ |
| 17 | + static int disassemble_zeroes; /* --disassemble-zeroes */ |
| 18 | + static bool formats_info; /* -i */ |
| 19 | + int wide_output; /* -w */ |
| 20 | +-static int insn_width; /* --insn-width */ |
| 21 | ++#define MAX_INSN_WIDTH 49 |
| 22 | ++static unsigned long insn_width; /* --insn-width */ |
| 23 | + static bfd_vma start_address = (bfd_vma) -1; /* --start-address */ |
| 24 | + static bfd_vma stop_address = (bfd_vma) -1; /* --stop-address */ |
| 25 | + static int dump_debugging; /* --debugging */ |
| 26 | +@@ -3315,7 +3316,7 @@ disassemble_bytes (struct disassemble_info *inf, |
| 27 | + } |
| 28 | + else |
| 29 | + { |
| 30 | +- char buf[50]; |
| 31 | ++ char buf[MAX_INSN_WIDTH + 1]; |
| 32 | + unsigned int bpc = 0; |
| 33 | + unsigned int pb = 0; |
| 34 | + |
| 35 | +@@ -5976,8 +5977,9 @@ main (int argc, char **argv) |
| 36 | + break; |
| 37 | + case OPTION_INSN_WIDTH: |
| 38 | + insn_width = strtoul (optarg, NULL, 0); |
| 39 | +- if (insn_width <= 0) |
| 40 | +- fatal (_("error: instruction width must be positive")); |
| 41 | ++ if (insn_width - 1 >= MAX_INSN_WIDTH) |
| 42 | ++ fatal (_("error: instruction width must be in the range 1 to " |
| 43 | ++ XSTRING (MAX_INSN_WIDTH))); |
| 44 | + break; |
| 45 | + case OPTION_INLINES: |
| 46 | + unwind_inlines = true; |
| 47 | +-- |
| 48 | +2.34.1 |
| 49 | + |
0 commit comments