From 2c4605a5a4433b1f573712c6b01e71409cd16c44 Mon Sep 17 00:00:00 2001 From: Pete Delaney Date: Fri, 5 Oct 2012 00:23:50 -0700 Subject: [PATCH] [MIPS] Updated support for stat. Change-Id: Ica3b92edb6718c19308da7370ced145ccaeb8d6d Signed-off-by: Chris Dearman Signed-off-by: Pete Delaney --- .../android/libportable/arch-mips/stat.c | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/ndk/sources/android/libportable/arch-mips/stat.c b/ndk/sources/android/libportable/arch-mips/stat.c index 6af5eeeb9..f8322c185 100644 --- a/ndk/sources/android/libportable/arch-mips/stat.c +++ b/ndk/sources/android/libportable/arch-mips/stat.c @@ -14,13 +14,22 @@ * limitations under the License. */ +#include #include +#include + /* Note: The Portable Header will define stat to stat_portable */ int stat_portable(const char *path, struct stat_portable *s) { struct stat mips_stat; - int ret = stat(path, &mips_stat); + int ret; + + if (invalid_pointer(s)) { + errno = EFAULT; + return -1; + } + ret = stat(path, &mips_stat); stat_ntop(&mips_stat, s); return ret; } @@ -28,7 +37,13 @@ int stat_portable(const char *path, struct stat_portable *s) int fstat_portable(int fd, struct stat_portable *s) { struct stat mips_stat; - int ret = fstat(fd, &mips_stat); + int ret; + + if (invalid_pointer(s)) { + errno = EFAULT; + return -1; + } + ret = fstat(fd, &mips_stat); stat_ntop(&mips_stat, s); return ret; } @@ -36,7 +51,13 @@ int fstat_portable(int fd, struct stat_portable *s) int lstat_portable(const char *path, struct stat_portable *s) { struct stat mips_stat; - int ret = lstat(path, &mips_stat); + int ret; + + if (invalid_pointer(s)) { + errno = EFAULT; + return -1; + } + ret = lstat(path, &mips_stat); stat_ntop(&mips_stat, s); return ret; } @@ -44,7 +65,13 @@ int lstat_portable(const char *path, struct stat_portable *s) int fstatat_portable(int dirfd, const char *path, struct stat_portable *s, int flags) { struct stat mips_stat; - int ret = fstatat(dirfd, path, &mips_stat, flags); + int ret; + + if (invalid_pointer(s)) { + errno = EFAULT; + return -1; + } + ret = fstatat(dirfd, path, &mips_stat, flags); stat_ntop(&mips_stat, s); return ret; }