Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Commit

Permalink
Klocwork SV.BANNED.* - Patch set 2: Code changes due to inspection no…
Browse files Browse the repository at this point in the history
…tes.

Signed-off-by: Juha Vainio <[email protected]>
  • Loading branch information
JuhaVainio authored and kwang13 committed May 14, 2020
1 parent d4ad0f6 commit 70a38c2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 21 deletions.
6 changes: 2 additions & 4 deletions installer.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,16 +720,14 @@ static CHAR16 *get_format_image_filename(CHAR8 *label)
filename16 = NULL;
goto out;
}
ret = memcpy_s(filename + label_length, SIZE_OF_FILENAME, ".img", 4);
ret = memcpy_s(filename + label_length, SIZE_OF_FILENAME - label_length, ".img", 4);
if (EFI_ERROR(ret)) {
filename16 = NULL;
goto out;
}
filename16 = stra_to_str(filename);
if (!filename16) {
if (!filename16)
fastboot_fail("Unable to allocate CHAR16 filename buffer");
filename16 = NULL;
}

out:
FreePool(filename);
Expand Down
4 changes: 2 additions & 2 deletions libfastboot/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ static EFI_STATUS flash_new_bootimage(VOID *kernel, UINTN kernel_size,

if (bootimage->header_version >= 1) {
ret = memcpy_s(new_bootimage + new_bootimage->recovery_acpio_offset,
bootimage->recovery_acpio_size,
new_bootimage->recovery_acpio_size,
bootimage + bootimage->recovery_acpio_offset,
bootimage->recovery_acpio_size);
if (EFI_ERROR(ret))
Expand All @@ -401,7 +401,7 @@ static EFI_STATUS flash_new_bootimage(VOID *kernel, UINTN kernel_size,

if (bootimage->header_version == 2) {
ret = memcpy_s(new_bootimage + new_bootimage->acpi_addr,
bootimage->acpi_size,
new_bootimage->acpi_size,
bootimage + bootimage->acpi_addr,
bootimage->acpi_size);
if (EFI_ERROR(ret))
Expand Down
2 changes: 1 addition & 1 deletion libkernelflinger/android.c
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ static EFI_STATUS setup_command_line(
char *vb_cmdline;
vb_cmdline = get_vb_cmdline(vb_data);
cmdline[cmdlen] = ' ';
ret = memcpy_s(cmdline + cmdlen + 1, vb_cmdlen, vb_cmdline, vb_cmdlen);
ret = memcpy_s(cmdline + cmdlen + 1, cmdsize, vb_cmdline, vb_cmdlen);
if (EFI_ERROR(ret)) {
free_pages(cmdline_addr, EFI_SIZE_TO_PAGES(cmdsize));
goto out;
Expand Down
18 changes: 4 additions & 14 deletions libkernelflinger/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ CHAR8 *strcpy(CHAR8 *dest, const CHAR8 *src)

EFI_STATUS strcpy_s(char *restrict dest, size_t destsz, const char *restrict src)
{
unsigned int i;

if (dest == src) {
debug(L"<strcpy_s dest == src");
return EFI_SUCCESS;
Expand All @@ -178,13 +180,6 @@ EFI_STATUS strcpy_s(char *restrict dest, size_t destsz, const char *restrict src
return EFI_BAD_BUFFER_SIZE;
}

if (src == NULL) {
error(L"<strcpy_s src == NULL");
while (destsz) { *dest = '\0'; destsz--; dest++; }
return EFI_INVALID_PARAMETER;
}

unsigned int i;
for (i = 0; src[i] != '\0'; i++)
dest[i] = src[i];
dest[i] = '\0';
Expand All @@ -194,6 +189,8 @@ EFI_STATUS strcpy_s(char *restrict dest, size_t destsz, const char *restrict src

EFI_STATUS strcpy16_s(CHAR16 *restrict dest, size_t destsz, const CHAR16 *restrict src)
{
unsigned int i;

if (dest == src) {
debug(L"<strcpy_s dest == src");
return EFI_SUCCESS;
Expand All @@ -209,13 +206,6 @@ EFI_STATUS strcpy16_s(CHAR16 *restrict dest, size_t destsz, const CHAR16 *restri
return EFI_BAD_BUFFER_SIZE;
}

if (src == NULL) {
error(L"<strcpy_s src == NULL");
while (destsz) { *dest = '\0'; destsz--; dest++; }
return EFI_INVALID_PARAMETER;
}

unsigned int i;
for (i = 0; src[i] != '\0'; i++)
dest[i] = src[i];
dest[i] = '\0';
Expand Down

0 comments on commit 70a38c2

Please sign in to comment.