diff mbox

example: classifier: fix buffer size warning

Message ID 1438269780-5826-1-git-send-email-bala.manoharan@linaro.org
State Accepted
Commit 188093383627240285947d7426b0eb6cb35e1bb8
Headers show

Commit Message

Balasubramanian Manoharan July 30, 2015, 3:23 p.m. UTC
Fixes: https://bugs.linaro.org/show_bug.cgi?id=1722

Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
---
 example/classifier/odp_classifier.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Maxim Uvarov Aug. 4, 2015, 10:05 a.m. UTC | #1
Merged,
Maxim.

On 07/30/15 18:23, Balasubramanian Manoharan wrote:
> Fixes: https://bugs.linaro.org/show_bug.cgi?id=1722
>
> Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
> ---
>   example/classifier/odp_classifier.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/example/classifier/odp_classifier.c b/example/classifier/odp_classifier.c
> index 53c7fdf..b55a6f9 100644
> --- a/example/classifier/odp_classifier.c
> +++ b/example/classifier/odp_classifier.c
> @@ -602,10 +602,12 @@ static int parse_pmr_policy(appl_args_t *appl_args, char *argv[], char *optarg)
>   	switch (term)	{
>   	case ODP_PMR_SIP_ADDR:
>   		token = strtok(NULL, ":");
> -		strncpy(stats[policy_count].value, token, DISPLAY_STRING_LEN);
> +		strncpy(stats[policy_count].value, token,
> +			DISPLAY_STRING_LEN - 1);
>   		parse_ipv4_addr(token, &stats[policy_count].rule.val);
>   		token = strtok(NULL, ":");
> -		strncpy(stats[policy_count].mask, token, DISPLAY_STRING_LEN);
> +		strncpy(stats[policy_count].mask, token,
> +			DISPLAY_STRING_LEN - 1);
>   		parse_ipv4_mask(token, &stats[policy_count].rule.mask);
>   		stats[policy_count].val_sz = 4;
>   	break;
> @@ -617,7 +619,7 @@ static int parse_pmr_policy(appl_args_t *appl_args, char *argv[], char *optarg)
>   	/* Queue Name */
>   	token = strtok(NULL, ":");
>   
> -	strncpy(stats[policy_count].queue_name, token, ODP_QUEUE_NAME_LEN);
> +	strncpy(stats[policy_count].queue_name, token, ODP_QUEUE_NAME_LEN - 1);
>   	appl_args->policy_count++;
>   	free(pmr_str);
>   	return 0;
diff mbox

Patch

diff --git a/example/classifier/odp_classifier.c b/example/classifier/odp_classifier.c
index 53c7fdf..b55a6f9 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -602,10 +602,12 @@  static int parse_pmr_policy(appl_args_t *appl_args, char *argv[], char *optarg)
 	switch (term)	{
 	case ODP_PMR_SIP_ADDR:
 		token = strtok(NULL, ":");
-		strncpy(stats[policy_count].value, token, DISPLAY_STRING_LEN);
+		strncpy(stats[policy_count].value, token,
+			DISPLAY_STRING_LEN - 1);
 		parse_ipv4_addr(token, &stats[policy_count].rule.val);
 		token = strtok(NULL, ":");
-		strncpy(stats[policy_count].mask, token, DISPLAY_STRING_LEN);
+		strncpy(stats[policy_count].mask, token,
+			DISPLAY_STRING_LEN - 1);
 		parse_ipv4_mask(token, &stats[policy_count].rule.mask);
 		stats[policy_count].val_sz = 4;
 	break;
@@ -617,7 +619,7 @@  static int parse_pmr_policy(appl_args_t *appl_args, char *argv[], char *optarg)
 	/* Queue Name */
 	token = strtok(NULL, ":");
 
-	strncpy(stats[policy_count].queue_name, token, ODP_QUEUE_NAME_LEN);
+	strncpy(stats[policy_count].queue_name, token, ODP_QUEUE_NAME_LEN - 1);
 	appl_args->policy_count++;
 	free(pmr_str);
 	return 0;