Fix sys-stat.c where a pointer to a mode_t (potentially an int16) was being unsafely...
authorAndi McClure <andi.mcclure@xamarin.com>
Mon, 23 Nov 2015 19:33:44 +0000 (14:33 -0500)
committerAndi McClure <andi.mcclure@xamarin.com>
Mon, 23 Nov 2015 19:33:44 +0000 (14:33 -0500)
support/sys-stat.c

index 52ab1cf46898e6a3f810341b656e6e211f453d40..d71d555b4d1b1c6f97f121d507356c06d35808b8 100644 (file)
@@ -30,9 +30,13 @@ Mono_Posix_FromStat (struct Mono_Posix_Stat *from, void *_to)
 
        to->st_dev         = from->st_dev;
        to->st_ino         = from->st_ino;
-       if (Mono_Posix_FromFilePermissions (from->st_mode, &to->st_mode) != 0) {
+
+       unsigned int to_st_mode;
+       if (Mono_Posix_FromFilePermissions (from->st_mode, &to_st_mode) != 0) {
                return -1;
        }
+
+       to->st_mode        = to_st_mode;
        to->st_nlink       = from->st_nlink;
        to->st_uid         = from->st_uid;
        to->st_gid         = from->st_gid;