[MIPS] Updated support for stat.
Change-Id: Ica3b92edb6718c19308da7370ced145ccaeb8d6d
Signed-off-by: Chris Dearman <chris@mips.com>
Signed-off-by: Pete Delaney <piet@mips.com>
diff --git a/ndk/sources/android/libportable/arch-mips/stat.c b/ndk/sources/android/libportable/arch-mips/stat.c
index 6af5eee..f8322c1 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 <errno.h>
#include <stat_portable.h>
+#include <portability.h>
+
/* 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 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 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 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;
}