ithewei 6 years ago
parent
commit
4e0bd33f21
1 changed files with 3 additions and 3 deletions
  1. 3 3
      base/hdir.cpp

+ 3 - 3
base/hdir.cpp

@@ -42,8 +42,8 @@ int listdir(const char* dir, std::list<hdir_t>& dirs) {
     hdir_t tmp;
     while (readdir_r(dp, &de, &result) == 0 && result) {
         memset(&tmp, 0, sizeof(hdir_t));
-        safe_strncpy(tmp.name, result->d_name, sizeof(tmp.name));
-        safe_strncpy(path+dirlen, result->d_name, sizeof(path)-dirlen);
+        strlcpy(tmp.name, result->d_name, sizeof(tmp.name));
+        strlcpy(path+dirlen, result->d_name, sizeof(path)-dirlen);
         if (lstat(path, &st) == 0) {
             if (S_ISREG(st.st_mode))        tmp.type = 'f';
             else if (S_ISDIR(st.st_mode))   tmp.type = 'd';
@@ -72,7 +72,7 @@ int listdir(const char* dir, std::list<hdir_t>& dirs) {
     hdir_t tmp;
     do {
         memset(&tmp, 0, sizeof(hdir_t));
-        safe_strncpy(tmp.name, data.cFileName, sizeof(tmp.name));
+        strlcpy(tmp.name, data.cFileName, sizeof(tmp.name));
         tmp.type = 'f';
         if (data.dwFileAttributes & _A_SUBDIR) {
             tmp.type = 'd';