From fea56ca790820d0e72c0b4daf0bd5d109b1c0e91 Mon Sep 17 00:00:00 2001 From: ayush-jha123 Date: Sat, 7 Mar 2026 07:54:13 +0000 Subject: [PATCH] MDEV-38010: Master/Relay Log Info files ignore trailing garbage in numeric lines This patch fixes an issue where Int_IO_CACHE::from_chars stops parsing at the first invalid character but fails to consume the remainder of the line. This caused trailing garbage on a numeric field (like Master_Port) to be interpreted as the value for the subsequent field. The fix adds a loop to consume the buffer up to the newline character or EOF if my_strtoll10 returns early. --- sql/rpl_info_file.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sql/rpl_info_file.h b/sql/rpl_info_file.h index 493598f7bf5a8..1b135dbf0a90f 100644 --- a/sql/rpl_info_file.h +++ b/sql/rpl_info_file.h @@ -66,9 +66,21 @@ namespace Int_IO_CACHE specific variants of a safe string-to-integer converter (e.g., std::from_chars() when all platforms support it). */ - if (*end == '\n' && value <= std::numeric_limits::max()) + if (value <= std::numeric_limits::max()) { value= static_cast(val); + /* + MDEV-38010: Consume the rest of the line if the buffer didn't reach the newline. + This handles cases where trailing garbage on a numeric line caused the + parser to stop early, leaving the garbage to corrupt the next line. + */ + if (buf[length - 1] != '\n') + { + int c; + do { + c= my_b_get(file); + } while (c != '\n' && c != my_b_EOF); + } return false; } [[fallthrough]];