diff options
author | ydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-09-20 03:20:56 +0000 |
---|---|---|
committer | ydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-09-20 03:20:56 +0000 |
commit | 80448f6c1aed17ee0fbfa79bab7e7b8eeb2eb084 (patch) | |
tree | 4a64cf4370a543ea299814c390a8a78fffd118ab /OptionRomPkg/AtapiPassThruDxe | |
parent | 1ca79586f441f34396c21df392ca34971f519c2d (diff) | |
download | edk2-platforms-80448f6c1aed17ee0fbfa79bab7e7b8eeb2eb084.tar.xz |
Refine some code to make code run safely.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10893 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'OptionRomPkg/AtapiPassThruDxe')
-rw-r--r-- | OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c b/OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c index d2a9d7b11e..3578a1e445 100644 --- a/OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c +++ b/OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c @@ -1749,10 +1749,12 @@ Returns: {
UINT8 Index;
UINT8 *OpCode;
+ UINT8 ArrayLen;
OpCode = (UINT8 *) (Packet->Cdb);
+ ArrayLen = (UINT8) (sizeof (gSupportedATAPICommands) / sizeof (gSupportedATAPICommands[0]));
- for (Index = 0; CompareMem (&gSupportedATAPICommands[Index], &gEndTable, sizeof (SCSI_COMMAND_SET)); Index++) {
+ for (Index = 0; (Index < ArrayLen) && (CompareMem (&gSupportedATAPICommands[Index], &gEndTable, sizeof (SCSI_COMMAND_SET)) != 0); Index++) {
if (*OpCode == gSupportedATAPICommands[Index].OpCode) {
//
@@ -1990,10 +1992,12 @@ Returns: {
UINT8 Index;
UINT8 *OpCode;
+ UINT8 ArrayLen;
OpCode = (UINT8 *) (Packet->Cdb);
+ ArrayLen = (UINT8) (sizeof (gSupportedATAPICommands) / sizeof (gSupportedATAPICommands[0]));
- for (Index = 0; CompareMem (&gSupportedATAPICommands[Index], &gEndTable, sizeof (SCSI_COMMAND_SET)); Index++) {
+ for (Index = 0; (Index < ArrayLen) && (CompareMem (&gSupportedATAPICommands[Index], &gEndTable, sizeof (SCSI_COMMAND_SET)) != 0); Index++) {
if (*OpCode == gSupportedATAPICommands[Index].OpCode) {
//
|