Discussion:
[edk2] [PATCH] ShellPkg: Refine the code logic of StrnCatGrow.
Qiu Shumin
1970-01-01 00:00:00 UTC
Permalink
In order to indicate the catena length use StrnCatS instead of StrCatS to generate Destination string, and update the DestMax of Destination string.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <***@intel.com>
---
ShellPkg/Library/UefiShellLib/UefiShellLib.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
index 5b4c6d3..3521515 100644
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
+++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
@@ -3254,7 +3254,8 @@ StrnCatGrow (
*CurrentSize = NewSize;
}
} else {
- *Destination = AllocateZeroPool((Count+1)*sizeof(CHAR16));
+ NewSize = (Count+1)*sizeof(CHAR16);
+ *Destination = AllocateZeroPool(NewSize);
}

//
@@ -3264,7 +3265,7 @@ StrnCatGrow (
return (NULL);
}

- StrCatS(*Destination, Count + 1, Source);
+ StrnCatS(*Destination, NewSize/sizeof(CHAR16), Source, Count);
return *Destination;
}
--
1.9.5.msysgit.1
Shah, Tapan
2015-07-01 14:22:22 UTC
Permalink
Reviewed-by: Tapan Shah <<***@hp.com>>

-----Original Message-----
From: Qiu Shumin [mailto:***@intel.com]
Sent: Tuesday, June 30, 2015 9:24 PM
To: edk2-***@lists.sourceforge.net
Cc: ***@intel.com; ***@intel.com; Shah, Tapan
Subject: [PATCH] ShellPkg: Refine the code logic of StrnCatGrow.

In order to indicate the catena length use StrnCatS instead of StrCatS to generate Destination string, and update the DestMax of Destination string.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <***@intel.com>
---
ShellPkg/Library/UefiShellLib/UefiShellLib.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
index 5b4c6d3..3521515 100644
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
+++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
@@ -3254,7 +3254,8 @@ StrnCatGrow (
*CurrentSize = NewSize;
}
} else {
- *Destination = AllocateZeroPool((Count+1)*sizeof(CHAR16));
+ NewSize = (Count+1)*sizeof(CHAR16);
+ *Destination = AllocateZeroPool(NewSize);
}

//
@@ -3264,7 +3265,7 @@ StrnCatGrow (
return (NULL);
}

- StrCatS(*Destination, Count + 1, Source);
+ StrnCatS(*Destination, NewSize/sizeof(CHAR16), Source, Count);
return *Destination;
}
--
1.9.5.msysgit.1
Carsey, Jaben
2015-07-01 18:52:18 UTC
Permalink
Post by Shah, Tapan
-----Original Message-----
Sent: Wednesday, July 01, 2015 7:22 AM
Cc: Fan, Jeff; Carsey, Jaben
Subject: RE: [PATCH] ShellPkg: Refine the code logic of StrnCatGrow.
Importance: High
-----Original Message-----
Sent: Tuesday, June 30, 2015 9:24 PM
Subject: [PATCH] ShellPkg: Refine the code logic of StrnCatGrow.
In order to indicate the catena length use StrnCatS instead of StrCatS to
generate Destination string, and update the DestMax of Destination string.
Contributed-under: TianoCore Contribution Agreement 1.0
---
ShellPkg/Library/UefiShellLib/UefiShellLib.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
index 5b4c6d3..3521515 100644
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
+++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
@@ -3254,7 +3254,8 @@ StrnCatGrow (
*CurrentSize = NewSize;
}
} else {
- *Destination = AllocateZeroPool((Count+1)*sizeof(CHAR16));
+ NewSize = (Count+1)*sizeof(CHAR16);
+ *Destination = AllocateZeroPool(NewSize);
}
//
@@ -3264,7 +3265,7 @@ StrnCatGrow (
return (NULL);
}
- StrCatS(*Destination, Count + 1, Source);
+ StrnCatS(*Destination, NewSize/sizeof(CHAR16), Source, Count);
return *Destination;
}
--
1.9.5.msysgit.1
Gary Ching-Pang Lin
2015-07-02 06:38:34 UTC
Permalink
Post by Qiu Shumin
In order to indicate the catena length use StrnCatS instead of StrCatS to generate Destination string, and update the DestMax of Destination string.
I just found the latest OVMF crashed when loading the shell, and this patch works for me.
Thanks for the patch.
Post by Qiu Shumin
Contributed-under: TianoCore Contribution Agreement 1.0
---
ShellPkg/Library/UefiShellLib/UefiShellLib.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
index 5b4c6d3..3521515 100644
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
+++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
@@ -3254,7 +3254,8 @@ StrnCatGrow (
*CurrentSize = NewSize;
}
} else {
- *Destination = AllocateZeroPool((Count+1)*sizeof(CHAR16));
+ NewSize = (Count+1)*sizeof(CHAR16);
+ *Destination = AllocateZeroPool(NewSize);
}
//
@@ -3264,7 +3265,7 @@ StrnCatGrow (
return (NULL);
}
- StrCatS(*Destination, Count + 1, Source);
+ StrnCatS(*Destination, NewSize/sizeof(CHAR16), Source, Count);
return *Destination;
}
--
1.9.5.msysgit.1
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
edk2-devel mailing list
https://lists.sourceforge.net/lists/listinfo/edk2-devel
Loading...