From: José Antonio Santos-Cadenas <santoscadenas@xxxxxxxxx> Minimum length responses are provided using a new macro to avoid using magic numbers in source code. --- mcap/mcap.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mcap/mcap.c b/mcap/mcap.c index 6031bd4..d3c92dc 100644 --- a/mcap/mcap.c +++ b/mcap/mcap.c @@ -35,6 +35,7 @@ #define RESPONSE_TIMER 2 /* seconds */ #define MAX_CACHED 10 /* 10 devices */ +#define MIN_RSP_LEN 4 /* 4 Bytes */ #define MCAP_ERROR g_quark_from_static_string("mcap-error-quark") @@ -1191,7 +1192,7 @@ static gboolean check_err_rsp(struct mcap_mcl *mcl, uint8_t *cmd, char *msg; /* Check if the response matches with the last request */ - if ((rlen < 4) || ((mcl->lcmd[0] + 1) != cmd[0])) { + if ((rlen < MIN_RSP_LEN) || ((mcl->lcmd[0] + 1) != cmd[0])) { msg = "Protocol error"; close = TRUE; goto fail; @@ -1349,7 +1350,7 @@ static gboolean process_md_abort_mdl_rsp(struct mcap_mcl *mcl, abrt_cb(gerr, user_data); - if ((len >= 4) && (rsp->rc == MCAP_INVALID_MDL)) { + if ((len >= MIN_RSP_LEN) && (rsp->rc == MCAP_INVALID_MDL)) { mcl->mdls = g_slist_remove(mcl->mdls, mdl); g_free(mdl); } -- 1.6.3.3 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html