From 3d99e9dbb6e288f06b522ae2d8894d4796cf594c Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Fri, 6 Mar 2015 19:48:47 +0000 Subject: [PATCH] Allow one extra byte in read_string() length to accomodate terminator The kenwood_transaction() function expects a buffer large enough for the null terminated command response less the Kenwood command terminator (';') but the read_string() call must allow an extra byte for that same terminator. --- kenwood/kenwood.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kenwood/kenwood.c b/kenwood/kenwood.c index d798034ae..b23d7402c 100644 --- a/kenwood/kenwood.c +++ b/kenwood/kenwood.c @@ -181,7 +181,7 @@ const struct confparams kenwood_cfg_params[] = { * indicating that only a reply is needed (nothing will be sent). * data: Buffer for reply string. Can be NULL, indicating that no reply * is needed and will return with RIG_OK after command was sent. - * datasize: in: Size of buffer. It is the caller's responsibily to provide + * datasize: Size of buffer. It is the caller's responsibily to provide * a large enough buffer for all possible replies for a command. * * returns: @@ -264,7 +264,8 @@ int kenwood_transaction(RIG *rig, const char *cmdstr, char *data, size_t datasiz } } - len = min (datasize ? datasize : strlen (verify) + 7, KENWOOD_MAX_BUF_LEN); + /* allow one extra byte for terminator we don't return */ + len = min (datasize ? datasize + 1 : strlen (verify) + 7, KENWOOD_MAX_BUF_LEN); retval = read_string(&rs->rigport, buffer, len, cmdtrm, strlen(cmdtrm)); if (retval < 0) { if (retry_read++ < rig->caps->retry)