Allocate buffer dynamically for input string 61/133261/3
authorHyunho Kang <hhstark.kang@samsung.com>
Fri, 9 Jun 2017 10:56:52 +0000 (19:56 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Mon, 12 Jun 2017 05:04:14 +0000 (05:04 +0000)
- To prevent buffer overflow

Change-Id: I1855e97ab27613757de49ce535895386a7842544
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
src/aul_rsc_mgr.c

index cab6a04..ce95c65 100755 (executable)
@@ -214,8 +214,8 @@ static void __bundle_iterator_get_valid_nodes(const char *key, const int type,
        bool *invalid = (bool *) data;
        bool ret_bool = true;
        int min, max;
-       char from[5] = { 0, };
-       char to[3] = { 0, };
+       char *from = NULL;
+       char *to = NULL;
        bool t_val;
        char *val;
        size_t size;
@@ -246,18 +246,26 @@ static void __bundle_iterator_get_valid_nodes(const char *key, const int type,
                        *invalid = true;
                break;
        case NODE_ATTR_SCREEN_DPI_RANGE:
-               sscanf(val, "%s %d %s %d", from, &min, to, &max);
+               sscanf(val, "%ms %d %ms %d", &from, &min, &to, &max);
                if (screen_dpi == -1)
                        screen_dpi = __get_dpi();
                if (!(min <= screen_dpi && screen_dpi <= max))
                        *invalid = true;
+               if (from)
+                       free(from);
+               if (to)
+                       free(to);
                break;
        case NODE_ATTR_SCREEN_WIDTH_RANGE:
-               sscanf(val, "%s %d %s %d", from, &min, to, &max);
+               sscanf(val, "%ms %d %ms %d", &from, &min, &to, &max);
                if (screen_width == -1)
                        screen_width = __get_screen_width();
                if (!(min <= screen_width && screen_width <= max))
                        *invalid = true;
+               if (from)
+                       free(from);
+               if (to)
+                       free(to);
                break;
        case NODE_ATTR_SCREEN_LARGE:
                if (!(strcmp(val, "true")))