projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix segfault in lutimes when tv argument is NULL
[musl]
/
src
/
dirent
/
scandir.c
diff --git
a/src/dirent/scandir.c
b/src/dirent/scandir.c
index
aad813a
..
7ee195d
100644
(file)
--- a/
src/dirent/scandir.c
+++ b/
src/dirent/scandir.c
@@
-1,10
+1,9
@@
#include <dirent.h>
#include <string.h>
#include <stdlib.h>
#include <dirent.h>
#include <string.h>
#include <stdlib.h>
-#include <
inttypes
.h>
+#include <
stdint
.h>
#include <errno.h>
#include <stddef.h>
#include <errno.h>
#include <stddef.h>
-#include <libc.h>
int scandir(const char *path, struct dirent ***res,
int (*sel)(const struct dirent *),
int scandir(const char *path, struct dirent ***res,
int (*sel)(const struct dirent *),
@@
-12,7
+11,7
@@
int scandir(const char *path, struct dirent ***res,
{
DIR *d = opendir(path);
struct dirent *de, **names=0, **tmp;
{
DIR *d = opendir(path);
struct dirent *de, **names=0, **tmp;
- size_t cnt=0, len=0
, size
;
+ size_t cnt=0, len=0;
int old_errno = errno;
if (!d) return -1;
int old_errno = errno;
if (!d) return -1;
@@
-26,10
+25,9
@@
int scandir(const char *path, struct dirent ***res,
if (!tmp) break;
names = tmp;
}
if (!tmp) break;
names = tmp;
}
- size = offsetof(struct dirent,d_name) + strlen(de->d_name) + 1;
- names[cnt] = malloc(size);
+ names[cnt] = malloc(de->d_reclen);
if (!names[cnt]) break;
if (!names[cnt]) break;
- memcpy(names[cnt++], de,
size
);
+ memcpy(names[cnt++], de,
de->d_reclen
);
}
closedir(d);
}
closedir(d);
@@
-46,4
+44,4
@@
int scandir(const char *path, struct dirent ***res,
return cnt;
}
return cnt;
}
-
LFS64(scandir
);
+
weak_alias(scandir, scandir64
);