fd passed to fdopendir is used internally by the implementation, and
should not otherwise be used by the application.
Change-Id: Ib8de3e9782f8e2455329acaecaeb43d2646c3a6d
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
size += __stat_size(&st);
}
+ /* fd passed to fdopendir is used internally by the implementation,
+ * and should not otherwise be used by the application.
+ * So we need to pass duplicated fd to fdopendir.
+ */
+ dfd = dup(dfd);
+ if (dfd == -1) {
+ LOGE("failed to duplicate fd, errno: %d (%s)", errno,
+ strerror_r(errno, buf, sizeof(buf)));
+ return -1;
+ }
dir = fdopendir(dfd);
if (dir == NULL) {
LOGE("fdopendir() failed, errno: %d (%s)", errno,