coverity: Fix coverity issue 18/226118/4 accepted/tizen/unified/20200228.123728 submit/tizen/20200227.094013
authorsanghyeok.oh <sanghyeok.oh@samsung.com>
Thu, 27 Feb 2020 04:14:03 +0000 (13:14 +0900)
committersanghyeok.oh <sanghyeok.oh@samsung.com>
Thu, 27 Feb 2020 08:12:50 +0000 (17:12 +0900)
Coverity: #1092538 Buffer not null terminated

Change-Id: Ib56db8edb211e819aa947f734894a1b757d5a518

tests/lowmem-system-env.cpp

index 65cc586..694899e 100644 (file)
@@ -131,7 +131,8 @@ std::pair<bool,struct dirent *> LowmemSystemEnv::readdir(DIR *dirp)
        (void) dirp;
        const char *dirname = mock_ptr_type(const char *);
        if (dirname) {
-               strncpy(local_dirent.d_name, dirname, sizeof(local_dirent.d_name));
+               strncpy(local_dirent.d_name, dirname, sizeof(local_dirent.d_name) - 1);
+               local_dirent.d_name[sizeof(local_dirent.d_name) - 1] = 0;
        } else {
                local_dirent.d_name[0] = 0;
        }