Author: gonzalo
Date: 2005-04-16 18:15:09 -0400 (Sat, 16 Apr 2005)
New Revision: 43133
Modified:
trunk/mono/mono/io-layer/ChangeLog
trunk/mono/mono/io-layer/handles-private.h
trunk/mono/mono/io-layer/handles.c
trunk/mono/mono/io-layer/io.c
Log:
2005-04-16 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* handles.c:
* io.c:
* handles-private.h: GetFileType wasn't checking if we have memory
allocated for the handle before dereferencing it. Fixes a FileStream
nunit test.
Modified: trunk/mono/mono/io-layer/ChangeLog
===================================================================
--- trunk/mono/mono/io-layer/ChangeLog 2005-04-16 21:59:05 UTC (rev 43132)
+++ trunk/mono/mono/io-layer/ChangeLog 2005-04-16 22:15:09 UTC (rev 43133)
@@ -1,6 +1,14 @@
2005-04-16 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* handles.c:
+ * io.c:
+ * handles-private.h: GetFileType wasn't checking if we have memory
+ allocated for the handle before dereferencing it. Fixes a FileStream
+ nunit test.
+
+2005-04-16 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+ * handles.c:
* processes.c:
* handles-private.h: we were calling g_renew to expand the handle array,
but that might move the memory and we might have pthread conditions or
Modified: trunk/mono/mono/io-layer/handles-private.h
===================================================================
--- trunk/mono/mono/io-layer/handles-private.h 2005-04-16 21:59:05 UTC (rev
43132)
+++ trunk/mono/mono/io-layer/handles-private.h 2005-04-16 22:15:09 UTC (rev
43133)
@@ -20,7 +20,10 @@
#include <mono/io-layer/misc-private.h>
#include <mono/io-layer/collection.h>
+#define _WAPI_PRIVATE_MAX_SLOTS 1024
#define _WAPI_PRIVATE_HANDLES(x) (_wapi_private_handles [x /
_WAPI_HANDLE_INITIAL_COUNT][x % _WAPI_HANDLE_INITIAL_COUNT])
+#define _WAPI_PRIVATE_HAVE_SLOT(x) ((GPOINTER_TO_UINT (x) /
_WAPI_PRIVATE_MAX_SLOTS) < _WAPI_PRIVATE_MAX_SLOTS && \
+ _wapi_private_handles [GPOINTER_TO_UINT
(x) / _WAPI_HANDLE_INITIAL_COUNT] != NULL)
#undef DEBUG
extern struct _WapiHandleUnshared *_wapi_private_handles [];
Modified: trunk/mono/mono/io-layer/handles.c
===================================================================
--- trunk/mono/mono/io-layer/handles.c 2005-04-16 21:59:05 UTC (rev 43132)
+++ trunk/mono/mono/io-layer/handles.c 2005-04-16 22:15:09 UTC (rev 43133)
@@ -86,7 +86,6 @@
* We can hold _WAPI_PRIVATE_MAX_SLOTS * _WAPI_HANDLE_INITIAL_COUNT handles.
* If 4M handles are not enough... Oh, well... we will crash.
*/
-#define _WAPI_PRIVATE_MAX_SLOTS 1024
#define SLOT_INDEX(x) (x / _WAPI_HANDLE_INITIAL_COUNT)
#define SLOT_OFFSET(x) (x % _WAPI_HANDLE_INITIAL_COUNT)
Modified: trunk/mono/mono/io-layer/io.c
===================================================================
--- trunk/mono/mono/io-layer/io.c 2005-04-16 21:59:05 UTC (rev 43132)
+++ trunk/mono/mono/io-layer/io.c 2005-04-16 22:15:09 UTC (rev 43133)
@@ -2182,6 +2182,11 @@
{
WapiHandleType type;
+ if (!_WAPI_PRIVATE_HAVE_SLOT (handle)) {
+ SetLastError (ERROR_INVALID_HANDLE);
+ return(FILE_TYPE_UNKNOWN);
+ }
+
type = _wapi_handle_type (handle);
if (io_ops[type].getfiletype == NULL) {
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches