Author: hbelusca Date: Thu Mar 26 14:52:16 2015 New Revision: 66903
URL: http://svn.reactos.org/svn/reactos?rev=66903&view=rev Log: [NTVDM] - Fix some english. - Validity checks for DosGetSftEntry returned pointer added. - Use unsigned indices for for-loops indices that are always positive.
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/bios.c trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/device.c trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/bios.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/d... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/bios.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/bios.c [iso-8859-1] Thu Mar 26 14:52:16 2015 @@ -56,6 +56,13 @@ BOOLEAN DosCheckInput(VOID) { PDOS_SFT_ENTRY SftEntry = DosGetSftEntry(DOS_INPUT_HANDLE); + + if (SftEntry == NULL) + { + /* Invalid handle */ + DosLastError = ERROR_INVALID_HANDLE; // ERROR_FILE_NOT_FOUND + return FALSE; + }
switch (SftEntry->Type) {
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/device.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/d... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/device.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/device.c [iso-8859-1] Thu Mar 26 14:52:16 2015 @@ -380,4 +380,4 @@ return Result; }
- +/* EOF */
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/d... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c [iso-8859-1] Thu Mar 26 14:52:16 2015 @@ -139,7 +139,7 @@
static inline PDOS_SFT_ENTRY DosFindFreeSftEntry(VOID) { - INT i; + UINT i;
for (i = 0; i < DOS_SFT_SIZE; i++) { @@ -154,7 +154,7 @@
static inline PDOS_SFT_ENTRY DosFindWin32SftEntry(HANDLE Handle) { - INT i; + UINT i;
for (i = 0; i < DOS_SFT_SIZE; i++) { @@ -170,7 +170,7 @@
static inline PDOS_SFT_ENTRY DosFindDeviceSftEntry(PDOS_DEVICE_NODE Device) { - INT i; + UINT i;
for (i = 0; i < DOS_SFT_SIZE; i++) { @@ -209,7 +209,6 @@
/* Check if the handle is already in the SFT */ SftEntry = DosFindWin32SftEntry(Handle); - if (SftEntry != NULL) { /* Already in the table, reference it */ @@ -266,7 +265,6 @@
/* Check if the device is already in the SFT */ SftEntry = DosFindDeviceSftEntry(Device); - if (SftEntry != NULL) { /* Already in the table, reference it */ @@ -301,7 +299,7 @@
static VOID DosCopyHandleTable(LPBYTE DestinationTable) { - INT i; + UINT i; PDOS_PSP PspBlock; LPBYTE SourceTable;
@@ -340,7 +338,6 @@ { /* Create a new SFT entry for it */ SftEntry = DosFindFreeSftEntry(); - if (SftEntry == NULL) { DPRINT1("Cannot create standard handle %d, the SFT is full!\n", i); @@ -1212,15 +1209,17 @@
BOOLEAN DosHandleIoctl(BYTE ControlCode, WORD FileHandle) { - PDOS_SFT_ENTRY Entry = DosGetSftEntry(FileHandle); - PDOS_DEVICE_NODE Node = Entry->DeviceNode; + PDOS_SFT_ENTRY SftEntry = DosGetSftEntry(FileHandle); + PDOS_DEVICE_NODE Node;
/* Make sure it exists and is a device */ - if (!Entry || Entry->Type != DOS_SFT_ENTRY_DEVICE) + if (!SftEntry || SftEntry->Type != DOS_SFT_ENTRY_DEVICE) { DosLastError = ERROR_FILE_NOT_FOUND; return FALSE; } + + Node = SftEntry->DeviceNode;
switch (ControlCode) { @@ -2620,7 +2619,7 @@ { PDOS_SFT_ENTRY SftEntry = DosGetSftEntry(getBX());
- if (SftEntry->Type != DOS_SFT_ENTRY_WIN32) + if (SftEntry == NULL || SftEntry->Type != DOS_SFT_ENTRY_WIN32) { /* The handle is invalid */ Stack[STACK_FLAGS] |= EMULATOR_FLAG_CF;
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/d... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c [iso-8859-1] Thu Mar 26 14:52:16 2015 @@ -41,7 +41,7 @@
// // The article about OpenFile API: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365430(v=vs.85).as... - // explains what are those AccessShareModes (see the uStyle flag). + // explains what those AccessShareModes are (see the uStyle flag). //
/* Parse the access mode */ @@ -228,7 +228,6 @@
/* Open the DOS handle */ DosHandle = DosOpenHandle(FileHandle); - if (DosHandle == INVALID_DOS_HANDLE) { /* Close the file and return the error code */ @@ -268,7 +267,6 @@
/* Open the DOS handle */ DosHandle = DosOpenHandle(FileHandle); - if (DosHandle == INVALID_DOS_HANDLE) { /* Close the file and return the error code */ @@ -297,7 +295,7 @@
// // The article about OpenFile API: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365430(v=vs.85).as... - // explains what are those AccessShareModes (see the uStyle flag). + // explains what those AccessShareModes are (see the uStyle flag). //
/* Parse the access mode */ @@ -380,7 +378,6 @@
/* Open the DOS handle */ DosHandle = DosOpenHandle(FileHandle); - if (DosHandle == INVALID_DOS_HANDLE) { /* Close the file and return the error code */ @@ -403,6 +400,12 @@
DPRINT("DosReadFile: FileHandle 0x%04X, Count 0x%04X\n", FileHandle, Count);
+ if (SftEntry == NULL) + { + /* Invalid handle */ + return ERROR_INVALID_HANDLE; + } + if (SftEntry->Type == DOS_SFT_ENTRY_WIN32) { DWORD BytesRead32 = 0; @@ -445,6 +448,12 @@
DPRINT("DosWriteFile: FileHandle 0x%04X, Count 0x%04X\n", FileHandle, Count);
+ if (SftEntry == NULL) + { + /* Invalid handle */ + return ERROR_INVALID_HANDLE; + } + if (SftEntry->Type == DOS_SFT_ENTRY_WIN32) { DWORD BytesWritten32 = 0; @@ -491,6 +500,12 @@ Offset, Origin);
+ if (SftEntry == NULL) + { + /* Invalid handle */ + return ERROR_INVALID_HANDLE; + } + if (SftEntry->Type == DOS_SFT_ENTRY_NONE) { /* Invalid handle */ @@ -534,6 +549,12 @@ { PDOS_SFT_ENTRY SftEntry = DosGetSftEntry(FileHandle);
+ if (SftEntry == NULL) + { + /* Invalid handle */ + return ERROR_INVALID_HANDLE; + } + switch (SftEntry->Type) { case DOS_SFT_ENTRY_WIN32: @@ -544,14 +565,10 @@ case DOS_SFT_ENTRY_DEVICE: { if (SftEntry->DeviceNode->FlushInputRoutine) - { SftEntry->DeviceNode->FlushInputRoutine(SftEntry->DeviceNode); - }
if (SftEntry->DeviceNode->FlushOutputRoutine) - { SftEntry->DeviceNode->FlushOutputRoutine(SftEntry->DeviceNode); - }
return TRUE; } @@ -563,3 +580,5 @@ } } } + +/* EOF */