From: Yunhee Seo Date: Thu, 14 Sep 2023 06:22:17 +0000 (+0900) Subject: feedback: Modify strncmp indexing comparison X-Git-Tag: accepted/tizen/unified/20230918.063835~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F08%2F298908%2F1;p=platform%2Fcore%2Fsystem%2Flibsvi.git feedback: Modify strncmp indexing comparison Final null character comparison was missing from strncmp length. To compare the end of the string, 1 index is added to strlen. Change-Id: Ied9505ba95eef0b5a41826704d506ae34c9d201a Signed-off-by: Yunhee Seo --- diff --git a/src/check.c b/src/check.c index 733d489..dcb79da 100644 --- a/src/check.c +++ b/src/check.c @@ -885,7 +885,7 @@ static int profile_get_pattern_enum(char *pattern) prof = get_profile(); - len = strlen(pattern); + len = strlen(pattern) + 1; //LCOV_EXCL_START if (prof == PROFILE_MOBILE) { for (i = 0; i < profile_get_num_of_pattern(); i++) { diff --git a/src/feedback-config.c b/src/feedback-config.c index 3be32fc..6964755 100644 --- a/src/feedback-config.c +++ b/src/feedback-config.c @@ -26,7 +26,7 @@ #define MAX_DATA 256 -#define MATCH(a, b) (!strncmp(a, b, strlen(a))) +#define MATCH(a, b) (!strncmp(a, b, strlen(a) + 1)) #define SET_CONF(a, b) (a = (b > 0.0 ? b : a)) static int load_config_index = 0; diff --git a/src/feedback.c b/src/feedback.c index 701c6ef..c0b6800 100644 --- a/src/feedback.c +++ b/src/feedback.c @@ -325,7 +325,7 @@ API int feedback_play_type_by_name(char *type, char *pattern) type_max = profile->max_type; for (etype = 0; etype < type_max; ++etype) { - if (!strncmp(type, profile->str_type[etype], strlen(type))) + if (!strncmp(type, profile->str_type[etype], strlen(type) + 1)) break; } @@ -336,7 +336,7 @@ API int feedback_play_type_by_name(char *type, char *pattern) pattern_max = profile->max_pattern; for (epattern = 0; epattern < pattern_max; ++epattern) { - if (!strncmp(pattern, profile->str_pattern(epattern), strlen(pattern))) + if (!strncmp(pattern, profile->str_pattern(epattern), strlen(pattern) + 1)) break; }