From 79655b07dcbf937f320c1477f77e044137adbf47 Mon Sep 17 00:00:00 2001 From: Dave Gosselin Date: Fri, 16 Oct 2026 13:09:17 -0400 Subject: [PATCH] MDEV-39173: Use snprintf in the remaining sprintf calls Convert all three calls to snprintf. 12.3 already has the same change for slave.cc, made in merge commit 9f98f82b14a. MDEV-39173 replaced sprintf with snprintf in 10.11 and removed the pragma in violite.h that hid deprecation warnings. Two calls in slave.cc and one in mysqltest.cc were added after 10.11, so 11.4 was out of date and produces sprintf deprecation warnings (at least on macOS). Co-Authored-By: Claude Opus 5.5 (1M context) --- client/mysqltest.cc | 3 ++- sql/slave.cc | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 0f0ecb37c41..6e7dfacd897 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -5350,7 +5350,8 @@ void do_sync_with_master2(struct st_command *command, long offset, /* master_pos_wait returned NULL or < 0 */ fprintf(stderr, "analyze: sync_with_master\n"); - sprintf(query_buf2, "show slave \"%s\" status", connection_name); + snprintf(query_buf2, sizeof(query_buf2), "show slave \"%s\" status", + connection_name); if (!mysql_query(mysql, query_buf2)) { diff --git a/sql/slave.cc b/sql/slave.cc index 9b844f0f371..89fd29f9ade 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2725,7 +2725,8 @@ after_set_capability: "The slave I/O thread stops because a fatal out-of-memory error " "is encountered when it tries to set " "@slave_gtid_until_before_gtids."; - sprintf(err_buff, "%s Error: Out of memory", errmsg); + snprintf(err_buff, sizeof(err_buff), "%s Error: Out of memory", + errmsg); goto err; } @@ -2745,7 +2746,8 @@ after_set_capability: /* Fatal error */ errmsg= "The slave I/O thread stops because a fatal error is " "encountered when it tries to set @slave_gtid_until_before_gtids."; - sprintf(err_buff, "%s Error: %s", errmsg, mysql_error(mysql)); + snprintf(err_buff, sizeof(err_buff), "%s Error: %s", errmsg, + mysql_error(mysql)); goto err; } }