diff --git a/ndk/sources/android/libportable/arch-mips/statfs.c b/ndk/sources/android/libportable/arch-mips/statfs.c index cd8b5afac..33ed1c66a 100644 --- a/ndk/sources/android/libportable/arch-mips/statfs.c +++ b/ndk/sources/android/libportable/arch-mips/statfs.c @@ -14,8 +14,11 @@ * limitations under the License. */ -#include #include +#include +#include + +#include static inline void statfs_ntop(struct statfs *n_statfs, struct statfs_portable *p_statfs) { @@ -35,7 +38,13 @@ static inline void statfs_ntop(struct statfs *n_statfs, struct statfs_portable * int statfs_portable(const char* path, struct statfs_portable* stat) { struct statfs mips_stat; - int ret = statfs(path, &mips_stat); + int ret; + + if (invalid_pointer(stat)) { + errno = EFAULT; + return -1; + } + ret = statfs(path, &mips_stat); statfs_ntop(&mips_stat, stat); return ret; } @@ -43,7 +52,13 @@ int statfs_portable(const char* path, struct statfs_portable* stat) int fstatfs_portable(int fd, struct statfs_portable* stat) { struct statfs mips_stat; - int ret = fstatfs(fd, &mips_stat); + int ret; + + if (invalid_pointer(stat)) { + errno = EFAULT; + return -1; + } + ret = fstatfs(fd, &mips_stat); statfs_ntop(&mips_stat, stat); return ret; }