bios_table.c (a16f70c55eca2c0e25f977a6a0774aeb14314e00) bios_table.c (d610b00e2e111a7854530d3fea1bdd2aca41b5f2)
1/* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
2#include "array.h"
3
4#include <libpldm/base.h>
5#include <libpldm/bios.h>
6#include <libpldm/bios_table.h>
7#include <libpldm/utils.h>
8

--- 908 unchanged lines hidden (view full) ---

917int pldm_bios_table_append_pad_checksum(void *table, size_t capacity,
918 size_t *size)
919{
920 if (!table || !size) {
921 return PLDM_ERROR_INVALID_DATA;
922 }
923
924 size_t pad_checksum_size = pldm_bios_table_pad_checksum_size(*size);
1/* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
2#include "array.h"
3
4#include <libpldm/base.h>
5#include <libpldm/bios.h>
6#include <libpldm/bios_table.h>
7#include <libpldm/utils.h>
8

--- 908 unchanged lines hidden (view full) ---

917int pldm_bios_table_append_pad_checksum(void *table, size_t capacity,
918 size_t *size)
919{
920 if (!table || !size) {
921 return PLDM_ERROR_INVALID_DATA;
922 }
923
924 size_t pad_checksum_size = pldm_bios_table_pad_checksum_size(*size);
925
926 if (SIZE_MAX - pad_checksum_size < *size) {
927 return PLDM_ERROR_INVALID_LENGTH;
928 }
929
925 size_t total_length = *size + pad_checksum_size;
926 if (capacity < total_length) {
927 return PLDM_ERROR_INVALID_LENGTH;
928 }
929
930 size_t total_length = *size + pad_checksum_size;
931 if (capacity < total_length) {
932 return PLDM_ERROR_INVALID_LENGTH;
933 }
934
935 if (UINTPTR_MAX - *size < (uintptr_t)table) {
936 return PLDM_ERROR_INVALID_LENGTH;
937 }
930 uint8_t *table_end = (uint8_t *)table + *size;
931 size_t pad_size = pad_size_get(*size);
932 table_end = pad_append(table_end, pad_size);
933
934 uint32_t checksum = crc32(table, *size + pad_size);
935 checksum_append(table_end, checksum);
936 *size = total_length;
937

--- 292 unchanged lines hidden ---
938 uint8_t *table_end = (uint8_t *)table + *size;
939 size_t pad_size = pad_size_get(*size);
940 table_end = pad_append(table_end, pad_size);
941
942 uint32_t checksum = crc32(table, *size + pad_size);
943 checksum_append(table_end, checksum);
944 *size = total_length;
945

--- 292 unchanged lines hidden ---