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