From: Yu Watanabe Date: Tue, 4 Mar 2025 15:05:31 +0000 (+0900) Subject: dirent-util: add several assertions in posix_getdents() X-Git-Tag: v258-rc1~1187 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c4eef179909147cec0c6ac3e2fa9989b24065fc0;p=thirdparty%2Fsystemd.git dirent-util: add several assertions in posix_getdents() Follow-up for e86a492ff08526e5adf85fa881c76f80adc3c84a. --- diff --git a/src/basic/dirent-util.h b/src/basic/dirent-util.h index 816b28e04fe..f3007b6bc30 100644 --- a/src/basic/dirent-util.h +++ b/src/basic/dirent-util.h @@ -34,6 +34,13 @@ struct dirent *readdir_no_dot(DIR *dirp); * Let's introduce a simple wrapper. */ #if !HAVE_POSIX_GETDENTS static inline ssize_t posix_getdents(int fd, void *buf, size_t nbyte, int flags) { + assert(fd >= 0); + assert(buf); + assert(nbyte > 0); + + if (flags != 0) + return -EINVAL; /* Currently flags must be zero. */ + return getdents64(fd, buf, nbyte); } #endif