Skip to content

Commit 8a714a4

Browse files
author
KJ5HST
committed
ftx1: use bounded %.*s in snprintf to silence GCC -Wformat-truncation
Replace "%s" with "%.*s" and explicit precision (sizeof(dst) - 1) in the four ret_data snapshot sites. Reported by N0NB on Debian 13 (GCC 14); clang and MinGW GCC did not trigger the warning.
1 parent 2b28d2e commit 8a714a4

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

rigs/yaesu/ftx1/ftx1_mem.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,14 @@ int ftx1_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
242242
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "FB;");
243243
if (newcat_get_cmd(rig) == RIG_OK)
244244
{
245-
snprintf(saved_fb, sizeof(saved_fb), "%s", priv->ret_data);
245+
snprintf(saved_fb, sizeof(saved_fb), "%.*s",
246+
(int)sizeof(saved_fb) - 1, priv->ret_data);
246247
}
247248
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "MD1;");
248249
if (newcat_get_cmd(rig) == RIG_OK)
249250
{
250-
snprintf(saved_md1, sizeof(saved_md1), "%s", priv->ret_data);
251+
snprintf(saved_md1, sizeof(saved_md1), "%.*s",
252+
(int)sizeof(saved_md1) - 1, priv->ret_data);
251253
}
252254

253255
/* 1. Point the Sub-side MC cursor at the target slot. The MC SET
@@ -456,12 +458,14 @@ static void ftx1_read_channel_tone_state(RIG *rig, int ch, int mr_p8,
456458
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "VM0;");
457459
if (newcat_get_cmd(rig) == RIG_OK)
458460
{
459-
snprintf(saved_vm, sizeof(saved_vm), "%s", priv->ret_data);
461+
snprintf(saved_vm, sizeof(saved_vm), "%.*s",
462+
(int)sizeof(saved_vm) - 1, priv->ret_data);
460463
}
461464
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "MC0;");
462465
if (newcat_get_cmd(rig) == RIG_OK)
463466
{
464-
snprintf(saved_mc, sizeof(saved_mc), "%s", priv->ret_data);
467+
snprintf(saved_mc, sizeof(saved_mc), "%.*s",
468+
(int)sizeof(saved_mc) - 1, priv->ret_data);
465469
}
466470

467471
/* Select the target memory channel. */

0 commit comments

Comments
 (0)