feedback: Modify strncmp indexing comparison 08/298908/1
authorYunhee Seo <yuni.seo@samsung.com>
Thu, 14 Sep 2023 06:22:17 +0000 (15:22 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Fri, 15 Sep 2023 05:42:25 +0000 (14:42 +0900)
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 <yuni.seo@samsung.com>
src/check.c
src/feedback-config.c
src/feedback.c

index 733d489..dcb79da 100644 (file)
@@ -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++) {
index 3be32fc..6964755 100644 (file)
@@ -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;
index 701c6ef..c0b6800 100644 (file)
@@ -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;
        }