+'Irp->Flags' sanity check
[captive.git] / src / libcaptive / storage / media.c
index 92d384d..3fd78f7 100644 (file)
@@ -288,7 +288,9 @@ const struct MajorFunction_READ_WRITE_func_Parameters *Parameters;
                g_assert(buffer==NULL);
                buffer=Irp->UserBuffer;
                }
-       if (Irp->AssociatedIrp.SystemBuffer) {
+       /* Forbid both IRP_BUFFERED_IO and IRP_ASSOCIATED_IRP as it should be IMO invalid state. */
+       g_assert(!((Irp->Flags & IRP_BUFFERED_IO) && (Irp->Flags & IRP_ASSOCIATED_IRP)));
+       if (Irp->Flags & IRP_BUFFERED_IO && Irp->AssociatedIrp.SystemBuffer) {
                g_assert(buffer==NULL);
                buffer=Irp->AssociatedIrp.SystemBuffer;
                }
@@ -296,7 +298,7 @@ const struct MajorFunction_READ_WRITE_func_Parameters *Parameters;
                /* See comment at ntoskrnl/io/buildirp.c/IoBuildSynchronousFsdRequestWithMdl()
                 * initialization of 'Irp->UserBuffer'.
                 */
-               g_assert(buffer==Irp->MdlAddress->StartVa);
+               g_assert(buffer==Irp->MdlAddress->StartVa || buffer==NULL);
                g_assert(Parameters->Length<=MmGetMdlByteCount(Irp->MdlAddress));
                buffer=MmGetSystemAddressForMdl(Irp->MdlAddress);
                }