Fix vulnerabilities 28/181528/1
authorSunmin Lee <sunm.lee@samsung.com>
Mon, 18 Sep 2017 04:27:50 +0000 (13:27 +0900)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Thu, 14 Jun 2018 11:29:06 +0000 (13:29 +0200)
Change-Id: Ia7d8565ef86cfef9d8b61e2e11020b6f1b49ed1d
Signed-off-by: Sunmin Lee <sunm.lee@samsung.com>
src/crash-stack/crash-stack.c

index 73d6bd26e521ce036a01257657c4712f501bf209..09de05c2decd7fe2849a1eecec2c3b675930185e 100644 (file)
@@ -646,7 +646,7 @@ static struct addr_node *get_addr_list_from_maps(int fd)
        /* parsing the maps to get executable code address */
        while (fgets_fd(linebuf, BUF_SIZE, fd) != NULL) {
                memset(path, 0, PATH_MAX);
-               result = sscanf(linebuf, "%s %s %*s %*s %*s %s ", addr, perm, path);
+               result = sscanf(linebuf, "%34s %5s %*s %*s %*s %256s ", addr, perm, path);
                if (result < 0)
                        continue;
                perm[PERM_LEN - 1] = 0;
@@ -757,7 +757,7 @@ static void __crash_stack_print_meminfo(FILE* outputfile, pid_t pid)
                fprintf(errfile, "[crash-stack] cannot open /proc/meminfo\n");
        } else {
                while (fgets_fd(linebuf, BUF_SIZE, fd) != NULL) {
-                       sscanf(linebuf, "%s %s %*s", infoname, memsize);
+                       sscanf(linebuf, "%16s %16s %*s", infoname, memsize);
                        if (strcmp("MemTotal:", infoname) == 0) {
                                fprintf(outputfile, "%s %8s KB\n", infoname, memsize);
                        } else if (strcmp("MemFree:", infoname) == 0) {
@@ -777,7 +777,7 @@ static void __crash_stack_print_meminfo(FILE* outputfile, pid_t pid)
                fprintf(errfile, "[crash-stack] cannot open %s\n", file_path);
        } else {
                while (fgets_fd(linebuf, BUF_SIZE, fd) != NULL) {
-                       sscanf(linebuf, "%s %s %*s", infoname, memsize);
+                       sscanf(linebuf, "%16s %16s %*s", infoname, memsize);
                        if (strcmp("VmPeak:", infoname) == 0) {
                                fprintf(outputfile, "%s   %8s KB\n", infoname,
                                                memsize);