From ea76b9e4955ae7e61969c6dd193e4f154dd39016 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 10 Jan 2022 23:22:38 -0600 Subject: [PATCH] Replace sprintf with snprintf in icom.c https://github.com/Hamlib/Hamlib/issues/857 --- rigs/icom/icom.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index f0758922c..215a672a5 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -4814,7 +4814,7 @@ int icom_set_conf(RIG *rig, token_t token, const char *val) * Assumes rig!=NULL, rig->state.priv!=NULL * and val points to a buffer big enough to hold the conf value. */ -int icom_get_conf(RIG *rig, token_t token, char *val) +int icom_get_conf2(RIG *rig, token_t token, char *val, int val_len) { struct icom_priv_data *priv; struct rig_state *rs; @@ -4826,13 +4826,13 @@ int icom_get_conf(RIG *rig, token_t token, char *val) switch (token) { case TOK_CIVADDR: - sprintf(val, "%d", priv->re_civ_addr); + SNPRINTF(val, val_len, "%d", priv->re_civ_addr); break; - case TOK_MODE731: sprintf(val, "%d", priv->civ_731_mode); + case TOK_MODE731: SNPRINTF(val, val_len, "%d", priv->civ_731_mode); break; - case TOK_NOXCHG: sprintf(val, "%d", priv->no_xchg); + case TOK_NOXCHG: SNPRINTF(val, val_len, "%d", priv->no_xchg); break; default: RETURNFUNC(-RIG_EINVAL); @@ -4841,6 +4841,12 @@ int icom_get_conf(RIG *rig, token_t token, char *val) RETURNFUNC(RIG_OK); } +int icom_get_conf(RIG *rig, token_t token, char *val) +{ + return icom_get_conf2(rig, token, val, 128); +} + + /* * icom_set_ptt