From db3afff112dcdabf7254f17bcb31dd476c2d406d Mon Sep 17 00:00:00 2001 From: Nate Bargmann Date: Sat, 7 Jan 2012 22:17:09 -0600 Subject: [PATCH] Assure NULL terminated strings in kit file. Various strncpy operations could result in a port pathname that is not a NULL terminated string as the allowed string length is the same size as the buffer per the strncpy manual page. This is corrected by assuring that the allowed length is FILPATHLEN - 1. --- kit/hiqsdr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kit/hiqsdr.c b/kit/hiqsdr.c index ae06c0d9b..299e3e3ff 100644 --- a/kit/hiqsdr.c +++ b/kit/hiqsdr.c @@ -198,7 +198,7 @@ static unsigned compute_sample_rate(const struct hiqsdr_priv_data *priv) rx_control = (unsigned)(priv->ref_clock / (8. * 8. * priv->sample_rate)) - 1; if (rx_control > 39) - rx_control = 39; + rx_control = 39; return rx_control; } @@ -269,7 +269,7 @@ int hiqsdr_init(RIG *rig) priv->split = RIG_SPLIT_OFF; priv->ref_clock = REFCLOCK; priv->sample_rate = DEFAULT_SAMPLE_RATE; - strncpy(rig->state.rigport.pathname, "192.168.2.196:48248", FILPATHLEN); + strncpy(rig->state.rigport.pathname, "192.168.2.196:48248", FILPATHLEN - 1); return RIG_OK; }