summaryrefslogtreecommitdiff
path: root/lib/ipmi_ekanalyzer.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2016-10-09 09:19:55 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2016-10-09 09:19:55 +0200
commit7ddeb3781f3d79ef1ae5a765a66f6cdd1ec113ef (patch)
tree3546836f27de4168559a62d8022626dfb101a133 /lib/ipmi_ekanalyzer.c
parent5bac665e38a15e6725f9ec17c7f7e80a0506aa08 (diff)
parent82ac6c87ce0b0af2fb8de25d70442fec406bb742 (diff)
Merge tag 'upstream/1.8.18'
Upstream version 1.8.18
Diffstat (limited to 'lib/ipmi_ekanalyzer.c')
-rw-r--r--lib/ipmi_ekanalyzer.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/lib/ipmi_ekanalyzer.c b/lib/ipmi_ekanalyzer.c
index d6ce4c7..7a6c63d 100644
--- a/lib/ipmi_ekanalyzer.c
+++ b/lib/ipmi_ekanalyzer.c
@@ -602,10 +602,13 @@ ipmi_ekanalyzer_main(struct ipmi_intf *intf, int argc, char **argv)
*/
filename_size = strlen(argv[index]) - SIZE_OF_FILE_TYPE + 1;
if (filename_size > 0) {
- /* TODO - check malloc() retval */
filename[i] = malloc( filename_size );
if (filename[i] != NULL) {
strcpy(filename[i], &argv[index][SIZE_OF_FILE_TYPE]);
+ } else {
+ lprintf(LOG_ERR, "ipmitool: malloc failure");
+ rc = ERROR_STATUS;
+ break;
}
}
rc = OK_STATUS;
@@ -2205,6 +2208,9 @@ ipmi_ek_create_amc_p2p_record(struct ipmi_ek_multi_header *record,
int index_oem = 0;
amc_record->oem_guid = malloc(amc_record->guid_count * \
sizeof(struct fru_picmgext_guid));
+ if (amc_record->oem_guid == NULL) {
+ return ERROR_STATUS;
+ }
for (index_oem = 0; index_oem < amc_record->guid_count;
index_oem++) {
memcpy(&amc_record->oem_guid[index_oem].guid,
@@ -2232,6 +2238,9 @@ ipmi_ek_create_amc_p2p_record(struct ipmi_ek_multi_header *record,
int ch_index = 0;
amc_record->ch_desc = malloc((amc_record->ch_count) * \
sizeof(struct fru_picmgext_amc_channel_desc_record));
+ if (amc_record->ch_desc == NULL) {
+ return ERROR_STATUS;
+ }
for (ch_index = 0; ch_index < amc_record->ch_count;
ch_index++) {
unsigned int data;
@@ -2255,6 +2264,9 @@ ipmi_ek_create_amc_p2p_record(struct ipmi_ek_multi_header *record,
int i=0;
amc_record->link_desc = malloc(amc_record->link_desc_count * \
sizeof(struct fru_picmgext_amc_link_desc_record));
+ if (amc_record->link_desc == NULL) {
+ return ERROR_STATUS;
+ }
for (i = 0; i< amc_record->link_desc_count; i++) {
unsigned int data[2];
struct fru_picmgext_amc_link_desc_record *src, *dst;
@@ -2767,7 +2779,6 @@ ipmi_ek_display_board_info_area(FILE *input_file, char *board_type,
lprintf(LOG_ERR, "ipmitool: malloc failure");
return (size_t)(-1);
}
-
ret = fread(additional_data, size_board, 1, input_file);
if ((ret != 1) || ferror(input_file)) {
lprintf(LOG_ERR, "Invalid Additional Data!");
@@ -3363,7 +3374,7 @@ ipmi_ek_display_board_p2p_record(struct ipmi_ek_multi_header *record)
printf("\n");
offset += sizeof(struct fru_picmgext_guid);
}
- for (offset;
+ for (offset = offset;
offset < record->header.len;
offset += sizeof(struct fru_picmgext_link_desc)) {
/* to solve little endian/big endian problem */
@@ -3522,7 +3533,7 @@ ipmi_ek_display_radial_ipmb0_record(struct ipmi_ek_multi_header *record)
if (record->data[offset] < 1) {
return;
}
- for (offset; offset < record->header.len;) {
+ for (offset = offset; offset < record->header.len;) {
unsigned char entry_count = 0;
printf(" IPMB-0 Hub Descriptor\n");
printf("\tHardware Address: 0x%02x\n",
@@ -4046,14 +4057,18 @@ ipmi_ekanalyzer_fru_file2structure(char *filename,
fseek(input_file, multi_offset, SEEK_SET);
while (!feof(input_file)) {
- /* TODO - check malloc() */
*list_record = malloc(sizeof(struct ipmi_ek_multi_header));
+ if (*list_record == NULL) {
+ lprintf(LOG_ERR, "ipmitool: malloc failure");
+ return ERROR_STATUS;
+ }
ret = fread(&(*list_record)->header, START_DATA_OFFSET, 1,
input_file);
if ((ret != 1) || ferror(input_file)) {
- /* TODO - no free?! */
- lprintf(LOG_ERR, "Invalid Header!");
+ free(*list_record);
+ *list_record = NULL;
fclose(input_file);
+ lprintf(LOG_ERR, "Invalid Header!");
return ERROR_STATUS;
}
if ((*list_record)->header.len == 0) {