diff --git a/NEWS b/NEWS index 65c8e9a91..579c527c1 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ Please send Hamlib bug reports to hamlib-developer@lists.sourceforge.net Version 5.x + * rig_get_conf deprecated and replaced by rig_get_conf2 * rot_get_conf deprecated and replaced by rot_get_conf2 * Asynchronous rig data output handling to support transceive and spectrum data. Mikael, OH3BHX * Multicast UDP packet output for asynchronous data. Mikael, OH3BHX @@ -15,6 +16,8 @@ Version 5.x Version 4.5 * 202?-??-?? + * New rig_get_conf2 to replace rig_get_conf buffer overflow potential + * New rot_get_conf2 to reaplce rot_get_conf buffer overflow potential * Added Barrett 4050 -- not functional yet * Added TCI 1.X -- not functional yet * Added TM-V71(A) diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 67e695773..309c6ec67 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -2007,6 +2007,7 @@ struct rig_caps { const unsigned char *frame); // this will be used to check rigcaps structure is compatible with client const char *hamlib_check_rig_caps; // a constant value we can check for hamlib integrity + int (*get_conf2)(RIG *rig, token_t token, char *val, int val_len); }; //! @endcond diff --git a/rigs/icmarine/icm710.c b/rigs/icmarine/icm710.c index 76e5f0289..734543746 100644 --- a/rigs/icmarine/icm710.c +++ b/rigs/icmarine/icm710.c @@ -165,6 +165,7 @@ const struct rig_caps icm710_caps = .cfgparams = icm710_cfg_params, .set_conf = icm710_set_conf, .get_conf = icm710_get_conf, + .get_conf2 = icm710_get_conf2, .priv = (void *)& icm710_priv_caps, .rig_init = icm710_init, @@ -356,7 +357,7 @@ int icm710_set_conf(RIG *rig, token_t token, const char *val) return RIG_OK; } -int icm710_get_conf(RIG *rig, token_t token, char *val) +int icm710_get_conf2(RIG *rig, token_t token, char *val, int val_len) { struct icm710_priv_data *priv; @@ -365,7 +366,7 @@ int icm710_get_conf(RIG *rig, token_t token, char *val) switch (token) { case TOK_REMOTEID: - sprintf(val, "%u", priv->remote_id); + snprintf(val, val_len, "%u", priv->remote_id); break; default: @@ -375,6 +376,11 @@ int icm710_get_conf(RIG *rig, token_t token, char *val) return RIG_OK; } +int icm710_get_conf(RIG *rig, token_t token, char *val) +{ + return icm710_get_conf2(rig, token, val, 128); +} + int icm710_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { char freqbuf[BUFSZ]; diff --git a/rigs/icmarine/icm710.h b/rigs/icmarine/icm710.h index 1a5c2b44b..ea2f926fb 100644 --- a/rigs/icmarine/icm710.h +++ b/rigs/icmarine/icm710.h @@ -77,6 +77,7 @@ int icm710_set_parm(RIG *rig, setting_t parm, value_t val); int icm710_get_parm(RIG *rig, setting_t parm, value_t *val); int icm710_set_conf(RIG *rig, token_t token, const char *val); int icm710_get_conf(RIG *rig, token_t token, char *val); +int icm710_get_conf2(RIG *rig, token_t token, char *val, int val_len); extern const struct rig_caps icm700pro_caps; extern const struct rig_caps icm710_caps; diff --git a/rigs/icmarine/icmarine.c b/rigs/icmarine/icmarine.c index 4766af16a..4e953a9f1 100644 --- a/rigs/icmarine/icmarine.c +++ b/rigs/icmarine/icmarine.c @@ -209,7 +209,7 @@ int icmarine_set_conf(RIG *rig, token_t token, const char *val) return RIG_OK; } -int icmarine_get_conf(RIG *rig, token_t token, char *val) +int icmarine_get_conf2(RIG *rig, token_t token, char *val, int val_len) { struct icmarine_priv_data *priv; @@ -218,7 +218,7 @@ int icmarine_get_conf(RIG *rig, token_t token, char *val) switch (token) { case TOK_REMOTEID: - sprintf(val, "%u", priv->remote_id); + snprintf(val, val_len, "%u", priv->remote_id); break; default: @@ -228,6 +228,11 @@ int icmarine_get_conf(RIG *rig, token_t token, char *val) return RIG_OK; } +int icmarine_get_conf(RIG *rig, token_t token, char *val) +{ + return icmarine_get_conf2(rig, token, val, 128); +} + /* * icmarine_transaction @@ -363,7 +368,7 @@ int icmarine_set_freq(RIG *rig, vfo_t vfo, freq_t freq) priv = (struct icmarine_priv_data *)rig->state.priv; - sprintf(freqbuf, "%.6f", freq / MHz(1)); + snprintf(freqbuf, sizeof(freqbuf), "%.6f", freq / MHz(1)); /* no error reporting upon TXFREQ failure */ if (RIG_SPLIT_OFF == priv->split) @@ -417,7 +422,7 @@ int icmarine_set_tx_freq(RIG *rig, vfo_t vfo, freq_t freq) rig_debug(RIG_DEBUG_TRACE, "%s:\n", __func__); - sprintf(freqbuf, "%.6f", freq / MHz(1)); + snprintf(freqbuf, sizeof(freqbuf), "%.6f", freq / MHz(1)); return icmarine_transaction(rig, CMD_TXFREQ, freqbuf, NULL); } @@ -718,17 +723,17 @@ int icmarine_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) switch (level) { case RIG_LEVEL_AF: - sprintf(lvlbuf, "%u", (unsigned)(val.f * 255)); + snprintf(lvlbuf, sizeof(lvlbuf), "%u", (unsigned)(val.f * 255)); retval = icmarine_transaction(rig, CMD_AFGAIN, lvlbuf, NULL); break; case RIG_LEVEL_RF: - sprintf(lvlbuf, "%u", (unsigned)(val.f * 9)); + snprintf(lvlbuf, sizeof(lvlbuf), "%u", (unsigned)(val.f * 9)); retval = icmarine_transaction(rig, CMD_RFGAIN, lvlbuf, NULL); break; case RIG_LEVEL_RFPOWER: - sprintf(lvlbuf, "%u", 1 + (unsigned)(val.f * 2)); + snprintf(lvlbuf, sizeof(lvlbuf), "%u", 1 + (unsigned)(val.f * 2)); retval = icmarine_transaction(rig, CMD_RFPWR, lvlbuf, NULL); break; diff --git a/rigs/icmarine/icmarine.h b/rigs/icmarine/icmarine.h index 6635988c8..9e4766fcc 100644 --- a/rigs/icmarine/icmarine.h +++ b/rigs/icmarine/icmarine.h @@ -69,6 +69,7 @@ int icmarine_set_parm(RIG *rig, setting_t parm, value_t val); int icmarine_get_parm(RIG *rig, setting_t parm, value_t *val); int icmarine_set_conf(RIG *rig, token_t token, const char *val); int icmarine_get_conf(RIG *rig, token_t token, char *val); +int icmarine_get_conf2(RIG *rig, token_t token, char *val, int val_len); extern const struct rig_caps icm700pro_caps; extern const struct rig_caps icm710_caps;