Replace strcpy to strncpy due to security reason. 90/152390/1
authorDongsun Lee <ds73.lee@samsung.com>
Tue, 26 Sep 2017 01:55:54 +0000 (10:55 +0900)
committerDong Sun Lee <ds73.lee@samsung.com>
Tue, 26 Sep 2017 04:03:20 +0000 (04:03 +0000)
Change-Id: Ib27a3aac775b40e95fb5344062a6600ae78737b7
(cherry picked from commit 2e965bbe41a43690cf9533cf12e05422652d05a1)

src/tef_libteec.c

index 5796d0d..a5f1914 100644 (file)
@@ -287,11 +287,13 @@ static void configParam(const char *p)
        }
        if (strncmp(p, "lib=", 4) == 0) {
                const char *libname = p + 4;
-               if (strlen(libname) > sizeof(config.libname) - 1) {
+               size_t libnamesize = strlen(libname);
+               if (libnamesize > sizeof(config.libname) - 1) {
                        fprintf(stderr, "tef-libteec: name to long '%s'\n", libname);
                        return;
                }
-               strcpy(config.libname, libname);
+               strncpy(config.libname, libname, libnamesize);
+               config.libname[libnamesize] = '\0';
        }
 }