Fix the return value of ifchd_cmd_str() and correct its length check.
This commit is contained in:
parent
17a2403635
commit
7ef7fa8a8d
@ -121,12 +121,12 @@ static int ifchd_cmd_str(char *buf, size_t buflen, char *optname,
|
|||||||
{
|
{
|
||||||
char *obuf = buf;
|
char *obuf = buf;
|
||||||
buf += snprintf(buf, buflen, "%s:", optname);
|
buf += snprintf(buf, buflen, "%s:", optname);
|
||||||
if (buflen < optlen + 1)
|
if (buflen < (buf - obuf) + optlen + 2)
|
||||||
return -1;
|
return -1;
|
||||||
memcpy(buf, optdata, optlen);
|
memcpy(buf, optdata, optlen);
|
||||||
buf[optlen] = ':';
|
buf[optlen] = ':';
|
||||||
buf[optlen+1] = '\0';
|
buf[optlen+1] = '\0';
|
||||||
return (buf - obuf) + optlen;
|
return (buf - obuf) + optlen + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define IFCHD_SW_CMD(x, y) case DCODE_##x: \
|
#define IFCHD_SW_CMD(x, y) case DCODE_##x: \
|
||||||
|
Loading…
Reference in New Issue
Block a user