windows: AFSQueryVolumeInfo exception info
authorJeffrey Altman <jaltman@your-file-system.com>
Wed, 6 Jun 2012 03:25:08 +0000 (23:25 -0400)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 6 Jun 2012 15:09:28 +0000 (08:09 -0700)
Protect against NULL FileObject or ObjectInformation.

Log additional information when an exception is caught in
AFSQueryVolumeInfo.

Change-Id: I6111345e53edc641f4d809839c1666f7a11a93d3
Reviewed-on: http://gerrit.openafs.org/7525
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>

src/WINNT/afsrdr/kernel/lib/AFSVolumeInfo.cpp

index 6d6343f..82b72d0 100644 (file)
@@ -50,7 +50,9 @@ AFSQueryVolumeInfo( IN PDEVICE_OBJECT LibDeviceObject,
     void *pBuffer = NULL;
     ULONG ulLength = 0;
     BOOLEAN bReleaseResource = FALSE;
+    PFILE_OBJECT pFileObject = NULL;
     AFSFcb *pFcb = NULL;
+    AFSObjectInfoCB *pObjectInfo = NULL;
     AFSVolumeCB *pVolumeCB = NULL;
 
     pIrpSp = IoGetCurrentIrpStackLocation( Irp);
@@ -58,7 +60,19 @@ AFSQueryVolumeInfo( IN PDEVICE_OBJECT LibDeviceObject,
     __try
     {
 
-        pFcb = (AFSFcb *)pIrpSp->FileObject->FsContext;
+        pFileObject = pIrpSp->FileObject;
+
+        if( pFileObject == NULL)
+        {
+
+            AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+                          AFS_TRACE_LEVEL_ERROR,
+                          "AFSQueryVolumeInfo Failing request with NULL FileObject\n");
+
+            try_return( ntStatus = STATUS_INVALID_DEVICE_REQUEST);
+        }
+
+        pFcb = (AFSFcb *)pFileObject->FsContext;
 
         if( pFcb == NULL)
         {
@@ -70,10 +84,22 @@ AFSQueryVolumeInfo( IN PDEVICE_OBJECT LibDeviceObject,
             try_return( ntStatus = STATUS_INVALID_DEVICE_REQUEST);
         }
 
-        pVolumeCB = pFcb->ObjectInformation->VolumeCB;
+        pObjectInfo = pFcb->ObjectInformation;
+
+        if( pObjectInfo == NULL)
+        {
+
+            AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+                          AFS_TRACE_LEVEL_ERROR,
+                          "AFSQueryVolumeInfo Failing request with NULL ObjectInformation\n");
+
+            try_return( ntStatus = STATUS_INVALID_DEVICE_REQUEST);
+        }
+
+        pVolumeCB = pObjectInfo->VolumeCB;
 
-        ASSERT( pVolumeCB->ObjectInformation.FileType == AFS_FILE_TYPE_DIRECTORY &&
-                pVolumeCB->ObjectInformation.FileId.Vnode == 1);
+        ASSERT( pObjectInfo->FileType == AFS_FILE_TYPE_DIRECTORY &&
+                pObjectInfo->FileId.Vnode == 1);
 
         ulLength = pIrpSp->Parameters.QueryVolume.Length;
         FsInformationClass = pIrpSp->Parameters.QueryVolume.FsInformationClass;
@@ -208,7 +234,12 @@ try_exit:
 
         AFSDbgLogMsg( 0,
                       0,
-                      "EXCEPTION - AFSQueryVolumeInfo\n");
+                      "EXCEPTION - AFSQueryVolumeInfo FO %08lX InfoClass %d FCB %08lX ObjectInfo %08lX VolCB %08lX\n",
+                      pFileObject,
+                      FsInformationClass,
+                      pFcb,
+                      pObjectInfo,
+                      pVolumeCB);
 
         AFSDumpTraceFilesFnc();
     }