[PATCH] utils.c: Fix wrong array index multiplication

4 views
Skip to first unread message

Andreas J. Reichel

unread,
Sep 11, 2018, 10:51:43 AM9/11/18
to efibootg...@googlegroups.com, Andreas Reichel
From: Andreas Reichel <andreas.r...@siemens.com>

gcc already handles that because of the pointer type

Signed-off-by: Andreas Reichel <andreas.r...@siemens.com>
---
utils.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/utils.c b/utils.c
index 8ba4663..3b0044c 100644
--- a/utils.c
+++ b/utils.c
@@ -311,8 +311,8 @@ CHAR16 *GetBootMediumPath(CHAR16 *input)

for (UINTN i = len; i > 0; i--)
{
- if (dst[i * sizeof(CHAR16)] == L'/') {
- dst[i * sizeof(CHAR16)] = L'\0';
+ if (dst[i] == L'/') {
+ dst[i] = L'\0';
break;
}
}
--
2.18.0

Jan Kiszka

unread,
Sep 11, 2018, 10:57:07 AM9/11/18
to [ext] Andreas J. Reichel, efibootg...@googlegroups.com
On 11.09.18 16:45, [ext] Andreas J. Reichel wrote:
> From: Andreas Reichel <andreas.r...@siemens.com>
>
> gcc already handles that because of the pointer type

Actually, other compilers as well :), but I applied the fix as is.

Thanks,
Jan

>
> Signed-off-by: Andreas Reichel <andreas.r...@siemens.com>
> ---
> utils.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/utils.c b/utils.c
> index 8ba4663..3b0044c 100644
> --- a/utils.c
> +++ b/utils.c
> @@ -311,8 +311,8 @@ CHAR16 *GetBootMediumPath(CHAR16 *input)
>
> for (UINTN i = len; i > 0; i--)
> {
> - if (dst[i * sizeof(CHAR16)] == L'/') {
> - dst[i * sizeof(CHAR16)] = L'\0';
> + if (dst[i] == L'/') {
> + dst[i] = L'\0';
> break;
> }
> }
>
--
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
Reply all
Reply to author
Forward
0 new messages