Преглед на файлове

Fix sys-stat.c where a pointer to a mode_t (potentially an int16) was being unsafely converted to an int32 pointer

Andi McClure преди 10 години
родител
ревизия
f4744df2fd
променени са 1 файла, в които са добавени 5 реда и са изтрити 1 реда
  1. 5 1
      support/sys-stat.c

+ 5 - 1
support/sys-stat.c

@@ -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;