| 
 | 1 | +From 5e9ec5c107d3f5b5179c3dbc19df43df041cd55b Mon Sep 17 00:00:00 2001  | 
 | 2 | +From: Michael Mann <mmann78@netscape.net>  | 
 | 3 | +Date: Fri, 20 Jun 2025 23:05:00 -0400  | 
 | 4 | +Subject: [PATCH 6/9] [CVE-2025-6170] Fix potential buffer overflows of  | 
 | 5 | + interactive shell  | 
 | 6 | + | 
 | 7 | +Fixes #941  | 
 | 8 | +---  | 
 | 9 | + debugXML.c | 15 ++++++++++-----  | 
 | 10 | + result/scripts/long_command | 8 ++++++++  | 
 | 11 | + test/scripts/long_command.script | 6 ++++++  | 
 | 12 | + test/scripts/long_command.xml | 1 +  | 
 | 13 | + 4 files changed, 25 insertions(+), 5 deletions(-)  | 
 | 14 | + create mode 100644 result/scripts/long_command  | 
 | 15 | + create mode 100644 test/scripts/long_command.script  | 
 | 16 | + create mode 100644 test/scripts/long_command.xml  | 
 | 17 | + | 
 | 18 | +diff --git a/debugXML.c b/debugXML.c  | 
 | 19 | +index ed56b0f8..452b9573 100644  | 
 | 20 | +--- a/debugXML.c  | 
 | 21 | ++++ b/debugXML.c  | 
 | 22 | +@@ -1033,6 +1033,10 @@ xmlCtxtDumpOneNode(xmlDebugCtxtPtr ctxt, xmlNodePtr node)  | 
 | 23 | + xmlCtxtGenericNodeCheck(ctxt, node);  | 
 | 24 | + }  | 
 | 25 | +   | 
 | 26 | ++#define MAX_PROMPT_SIZE 500  | 
 | 27 | ++#define MAX_ARG_SIZE 400  | 
 | 28 | ++#define MAX_COMMAND_SIZE 100  | 
 | 29 | ++  | 
 | 30 | + /**  | 
 | 31 | + * xmlCtxtDumpNode:  | 
 | 32 | + * @output: the FILE * for the output  | 
 | 33 | +@@ -2795,10 +2799,10 @@ void  | 
 | 34 | + xmlShell(xmlDocPtr doc, const char *filename, xmlShellReadlineFunc input,  | 
 | 35 | + FILE * output)  | 
 | 36 | + {  | 
 | 37 | +- char prompt[500] = "/ > ";  | 
 | 38 | ++ char prompt[MAX_PROMPT_SIZE] = "/ > ";  | 
 | 39 | + char *cmdline = NULL, *cur;  | 
 | 40 | +- char command[100];  | 
 | 41 | +- char arg[400];  | 
 | 42 | ++ char command[MAX_COMMAND_SIZE];  | 
 | 43 | ++ char arg[MAX_ARG_SIZE];  | 
 | 44 | + int i;  | 
 | 45 | + xmlShellCtxtPtr ctxt;  | 
 | 46 | + xmlXPathObjectPtr list;  | 
 | 47 | +@@ -2856,7 +2860,8 @@ xmlShell(xmlDocPtr doc, const char *filename, xmlShellReadlineFunc input,  | 
 | 48 | + cur++;  | 
 | 49 | + i = 0;  | 
 | 50 | + while ((*cur != ' ') && (*cur != '\t') &&  | 
 | 51 | +- (*cur != '\n') && (*cur != '\r')) {  | 
 | 52 | ++ (*cur != '\n') && (*cur != '\r') &&  | 
 | 53 | ++ (i < (MAX_COMMAND_SIZE - 1))) {  | 
 | 54 | + if (*cur == 0)  | 
 | 55 | + break;  | 
 | 56 | + command[i++] = *cur++;  | 
 | 57 | +@@ -2871,7 +2876,7 @@ xmlShell(xmlDocPtr doc, const char *filename, xmlShellReadlineFunc input,  | 
 | 58 | + while ((*cur == ' ') || (*cur == '\t'))  | 
 | 59 | + cur++;  | 
 | 60 | + i = 0;  | 
 | 61 | +- while ((*cur != '\n') && (*cur != '\r') && (*cur != 0)) {  | 
 | 62 | ++ while ((*cur != '\n') && (*cur != '\r') && (*cur != 0) && (i < (MAX_ARG_SIZE-1))) {  | 
 | 63 | + if (*cur == 0)  | 
 | 64 | + break;  | 
 | 65 | + arg[i++] = *cur++;  | 
 | 66 | +diff --git a/result/scripts/long_command b/result/scripts/long_command  | 
 | 67 | +new file mode 100644  | 
 | 68 | +index 00000000..e6f00708  | 
 | 69 | +--- /dev/null  | 
 | 70 | ++++ b/result/scripts/long_command  | 
 | 71 | +@@ -0,0 +1,8 @@  | 
 | 72 | ++/ > b > b > Object is a Node Set :  | 
 | 73 | ++Set contains 1 nodes:  | 
 | 74 | ++1 ELEMENT a:c  | 
 | 75 | ++b > Unknown command This_is_a_really_long_command_string_designed_to_test_the_limits_of_the_memory_that_stores_the_comm  | 
 | 76 | ++b > b > Unknown command ess_currents_of_time_and_existence  | 
 | 77 | ++b > <?xml version="1.0"?>  | 
 | 78 | ++<a xmlns:a="bar"><b xmlns:a="foo">Navigating_the_labyrinthine_corridors_of_human_cognition_one_often_encounters_the_perplexing_paradox_that_the_more_we_delve_into_the_intricate_dance_of_neural_pathways_and_synaptic_firings_the_further_we_seem_to_stray_from_a_truly_holistic_understanding_of_consciousness_a_phenomenon_that_remains_as_elusive_as_a_moonbeam_caught_in_a_spiderweb_yet_undeniably_shapes_every_fleeting_thought_every_prof</b></a>  | 
 | 79 | ++b >   | 
 | 80 | +\ No newline at end of file  | 
 | 81 | +diff --git a/test/scripts/long_command.script b/test/scripts/long_command.script  | 
 | 82 | +new file mode 100644  | 
 | 83 | +index 00000000..00f6df09  | 
 | 84 | +--- /dev/null  | 
 | 85 | ++++ b/test/scripts/long_command.script  | 
 | 86 | +@@ -0,0 +1,6 @@  | 
 | 87 | ++cd a/b  | 
 | 88 | ++set <a:c/>  | 
 | 89 | ++xpath //*[namespace-uri()="foo"]  | 
 | 90 | ++This_is_a_really_long_command_string_designed_to_test_the_limits_of_the_memory_that_stores_the_command_please_dont_crash foo  | 
 | 91 | ++set Navigating_the_labyrinthine_corridors_of_human_cognition_one_often_encounters_the_perplexing_paradox_that_the_more_we_delve_into_the_intricate_dance_of_neural_pathways_and_synaptic_firings_the_further_we_seem_to_stray_from_a_truly_holistic_understanding_of_consciousness_a_phenomenon_that_remains_as_elusive_as_a_moonbeam_caught_in_a_spiderweb_yet_undeniably_shapes_every_fleeting_thought_every_profound_emotion_and_every_grand_aspiration_that_propels_our_species_ever_onward_through_the_relentless_currents_of_time_and_existence  | 
 | 92 | ++save -  | 
 | 93 | +diff --git a/test/scripts/long_command.xml b/test/scripts/long_command.xml  | 
 | 94 | +new file mode 100644  | 
 | 95 | +index 00000000..1ba44016  | 
 | 96 | +--- /dev/null  | 
 | 97 | ++++ b/test/scripts/long_command.xml  | 
 | 98 | +@@ -0,0 +1 @@  | 
 | 99 | ++<a xmlns:a="bar"><b xmlns:a="foo"/></a>  | 
 | 100 | +--   | 
 | 101 | +2.50.1  | 
 | 102 | + | 
0 commit comments