]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/Misc.c
pointer verification (not NULL) and buffer overrun fixes.
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / HexEdit / Misc.c
index 8ae21450c4978247828a3e46b5957dca5b477b9c..da11789625635ff730d806e0eb17d25480dd7564 100644 (file)
@@ -256,10 +256,10 @@ Returns:
   //     do not set currentline to Line\r
   //\r
   if (Count <= 0) {\r
-    AbsCount  = -Count;\r
+    AbsCount  = (UINTN)ABS(Count);\r
     Line      = _HLineRetreat (AbsCount);\r
   } else {\r
-    Line = _HLineAdvance (Count);\r
+    Line = _HLineAdvance ((UINTN)Count);\r
   }\r
 \r
   return Line;\r
@@ -297,10 +297,10 @@ Returns:
   // >0: advance\r
   //\r
   if (Count <= 0) {\r
-    AbsCount  = -Count;\r
+    AbsCount  = (UINTN)ABS(Count);\r
     Line      = _HLineRetreat (AbsCount);\r
   } else {\r
-    Line = _HLineAdvance (Count);\r
+    Line = _HLineAdvance ((UINTN)Count);\r
   }\r
 \r
   if (Line == NULL) {\r
@@ -399,7 +399,10 @@ Returns:
   Lenp        = StrLen (Pat);\r
   Lens        = StrLen (Str);\r
 \r
-  Failure     = AllocateZeroPool (Lenp * sizeof (INTN));\r
+  Failure     = AllocateZeroPool ((UINTN)(Lenp * sizeof (INTN)));\r
+  if (Failure == NULL) {\r
+    return 0;\r
+  }\r
   Failure[0]  = -1;\r
   for (j = 1; j < Lenp; j++) {\r
     i = Failure[j - 1];\r