From: Allura u. <al...@ch...> - 2017-02-12 06:58:17
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "ipmitool". The branch, master has been updated via 497f7767cd8e80ad67d08680ae165271441017fc (commit) via 7b0302cef5b7f22bd707f0d07c4098d7a6c57aa6 (commit) via 840f5730831b0d7cdb976b07e6c9c1aafc86f978 (commit) via 41fa699ae9480435cb888fa52405734e0ef6f349 (commit) via b35a6349087e64406ff6d4787c0612ae982ab4c4 (commit) via bc7d23761d07e67dad91c9d1dfb140c7d07c1a12 (commit) via e45dc6234bf887fa8356684c13f2468c3041c542 (commit) from 5db314f694f75c575cd7c9ffe9ee57aaf3a88866 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 497f7767cd8e80ad67d08680ae165271441017fc Author: Alexander Amelkin <ale...@am...> Date: Thu Feb 2 15:25:44 2017 +0300 ID:477 - fru: Fix decoding of non-text data in get_fru_area_str() The get_fru_area_str() function is used to decode FRU area fields into text. Areas may be encoded as text, binary, BCDplus or 6-bit ASCII. Decoding of 6-bit ASCII and BCDplus was broken. There was an error in the formulas used to calculate the resulting string length, plus the decoding formulas for BCDplus was wrong. For BCDplus the resulting length was considered equal the encoded data length, while in fact it's twice as big. Only one character instead of two was being extracted from a single input byte while two nibbles must have been taken into account. For 6-bit ASCII rounding of 3 to 4 bytes conversion was done improperly adding 2 to the original length instead of the result of multiplication. diff --git a/lib/ipmi_fru.c b/lib/ipmi_fru.c index cf00eff..42c1f19 100644 --- a/lib/ipmi_fru.c +++ b/lib/ipmi_fru.c @@ -107,7 +107,7 @@ char * get_fru_area_str(uint8_t * data, uint32_t * offset) { static const char bcd_plus[] = "0123456789 -.:,_"; char * str; - int len, off, size, i, j, k, typecode; + int len, off, size, i, j, k, typecode, char_idx; union { uint32_t bits; char chars[4]; @@ -126,15 +126,15 @@ char * get_fru_area_str(uint8_t * data, uint32_t * offset) switch (typecode) { case 0: /* 00b: binary/unspecified */ - /* hex dump -> 2x length */ - size = (len*2); + case 1: /* 01b: BCD plus */ + /* hex dump or BCD -> 2x length */ + size = (len * 2); break; case 2: /* 10b: 6-bit ASCII */ /* 4 chars per group of 1-3 bytes */ - size = ((((len+2)*4)/3) & ~3); + size = (((len * 4 + 2) / 3) & ~3); break; case 3: /* 11b: 8-bit ASCII */ - case 1: /* 01b: BCD plus */ /* no length adjustment */ size = len; break; @@ -149,7 +149,7 @@ char * get_fru_area_str(uint8_t * data, uint32_t * offset) return NULL; memset(str, 0, size+1); - if (len == 0) { + if (size == 0) { str[0] = '\0'; *offset = off; return str; @@ -157,30 +157,30 @@ char * get_fru_area_str(uint8_t * data, uint32_t * offset) switch (typecode) { case 0: /* Binary */ - strncpy(str, buf2str(&data[off], len), len*2); + strncpy(str, buf2str(&data[off], len), size); break; case 1: /* BCD plus */ - for (k=0; k<len; k++) - str[k] = bcd_plus[(data[off+k] & 0x0f)]; + for (k = 0; k < size; k++) + str[k] = bcd_plus[((data[off + k / 2] >> ((k % 2) ? 0 : 4)) & 0x0f)]; str[k] = '\0'; break; case 2: /* 6-bit ASCII */ - for (i=j=0; i<len; i+=3) { + for (i = j = 0; i < len; i += 3) { u.bits = 0; - k = ((len-i) < 3 ? (len-i) : 3); + k = ((len - i) < 3 ? (len - i) : 3); #if WORDS_BIGENDIAN u.chars[3] = data[off+i]; u.chars[2] = (k > 1 ? data[off+i+1] : 0); u.chars[1] = (k > 2 ? data[off+i+2] : 0); -#define CHAR_IDX 3 + char_idx = 3; #else memcpy((void *)&u.bits, &data[off+i], k); -#define CHAR_IDX 0 + char_idx = 0; #endif for (k=0; k<4; k++) { - str[j++] = ((u.chars[CHAR_IDX] & 0x3f) + 0x20); + str[j++] = ((u.chars[char_idx] & 0x3f) + 0x20); u.bits >>= 6; } } @@ -188,8 +188,8 @@ char * get_fru_area_str(uint8_t * data, uint32_t * offset) break; case 3: - memcpy(str, &data[off], len); - str[len] = '\0'; + memcpy(str, &data[off], size); + str[size] = '\0'; break; } commit 7b0302cef5b7f22bd707f0d07c4098d7a6c57aa6 Author: Alexander Amelkin <ale...@am...> Date: Tue Jan 24 14:09:57 2017 +0300 ID:479 - ekanalyzer: fix processing of custom mfg. fields Ekanalyzer was not reading the type/length byte for the 2nd and subsequent custom fields. Also the message it displayed when lacked data for custom fields was very relaxing and incorrect. diff --git a/lib/ipmi_ekanalyzer.c b/lib/ipmi_ekanalyzer.c index 35aa850..f6d8b90 100644 --- a/lib/ipmi_ekanalyzer.c +++ b/lib/ipmi_ekanalyzer.c @@ -2697,6 +2697,7 @@ ipmi_ek_display_board_info_area(FILE *input_file, char *board_type, int ret = 0; unsigned char len = 0; unsigned int size_board = 0; + int custom_fields = 0; if (input_file == NULL || board_type == NULL || board_length == NULL) { return (size_t)(-1); @@ -2758,7 +2759,12 @@ ipmi_ek_display_board_info_area(FILE *input_file, char *board_type, /* take the rest of data in the area minus 1 byte of * checksum */ - printf("Additional Custom Mfg. length: 0x%02x\n", len); + if (custom_fields) { + printf("End of Custom Mfg. fields (0x%02x)\n", len); + } else { + printf("No Additional Custom Mfg. fields (0x%02x)\n", len); + } + padding = (*board_length) - 1; if ((padding > 0) && (!feof(input_file))) { printf("Unused space: %d (bytes)\n", padding); @@ -2772,6 +2778,7 @@ ipmi_ek_display_board_info_area(FILE *input_file, char *board_type, printf("Checksum: 0x%02x\n", checksum); goto out; } + custom_fields++; printf("Additional Custom Mfg. length: 0x%02x\n", len); if ((size_board > 0) && (size_board < (*board_length))) { unsigned char *additional_data, *str; @@ -2801,9 +2808,17 @@ ipmi_ek_display_board_info_area(FILE *input_file, char *board_type, additional_data = NULL; (*board_length) -= size_board; + ret = fread(&len, 1, 1, input_file); + if ((ret != 1) || ferror(input_file)) { + lprintf(LOG_ERR, "Invalid Length!"); + goto out; + } + (*board_length)--; + size_board = (len & 0x3f); } else { - printf("No Additional Custom Mfg. %d\n", *board_length); + printf("ERROR: File has insufficient data (%d bytes) for the " + "Additional Custom Mfg. field\n", *board_length); goto out; } } commit 840f5730831b0d7cdb976b07e6c9c1aafc86f978 Author: Alexander Amelkin <ale...@am...> Date: Mon Jan 23 12:47:35 2017 +0300 ID:478 - ekanalyzer: Fixed decoding of FRU fields Got rid of the field decoding code that was only capable of processing ASCII and binary fields, and switched to using get_fru_area_str() that can also decode BCDplus and 6-bit ASCII and maybe will eventually be enabled to decode Unicode text as well. This is the first step to completely get rid of the completely awfully written FRU data decoding functionality of ekanalyzer that essentially duplicates that of ipmi_fru.c module. diff --git a/include/ipmitool/ipmi_fru.h b/include/ipmitool/ipmi_fru.h index 65696ba..d03abfc 100644 --- a/include/ipmitool/ipmi_fru.h +++ b/include/ipmitool/ipmi_fru.h @@ -614,5 +614,6 @@ typedef struct ipmi_fru_bloc { int ipmi_fru_main(struct ipmi_intf *intf, int argc, char **argv); int ipmi_fru_print(struct ipmi_intf *intf, struct sdr_record_fru_locator *fru); +char *get_fru_area_str(uint8_t *data, uint32_t *offset); #endif /* IPMI_FRU_H */ diff --git a/lib/ipmi_ekanalyzer.c b/lib/ipmi_ekanalyzer.c index 7a6c63d..35aa850 100644 --- a/lib/ipmi_ekanalyzer.c +++ b/lib/ipmi_ekanalyzer.c @@ -37,6 +37,7 @@ #include <ipmitool/log.h> #include <ipmitool/helper.h> #include <ipmitool/ipmi_strings.h> +#include <ipmitool/ipmi_fru.h> #include <stdlib.h> #include <string.h> @@ -2702,6 +2703,12 @@ ipmi_ek_display_board_info_area(FILE *input_file, char *board_type, } file_offset = ftell(input_file); + /* + * TODO: This whole file's code is extremely dirty and wicked. + * Must eventually switch to using ipmi_fru.c code or some + * specialized FRU library. + */ + /* Board length*/ ret = fread(&len, 1, 1, input_file); if ((ret != 1) || ferror(input_file)) { @@ -2717,14 +2724,15 @@ ipmi_ek_display_board_info_area(FILE *input_file, char *board_type, goto out; } if (strncmp(board_type, "Custom", 6 ) != 0) { - unsigned char *data; + unsigned char *data, *str; unsigned int i = 0; - data = malloc(size_board); + data = malloc(size_board + 1); /* Make room for type/length field */ if (data == NULL) { lprintf(LOG_ERR, "ipmitool: malloc failure"); return (size_t)(-1); } - ret = fread(data, size_board, 1, input_file); + data[0] = len; /* Save the type/length byte in 'data' */ + ret = fread(data + 1, size_board, 1, input_file); if ((ret != 1) || ferror(input_file)) { lprintf(LOG_ERR, "Invalid board type size!"); free(data); @@ -2733,17 +2741,11 @@ ipmi_ek_display_board_info_area(FILE *input_file, char *board_type, } printf("%s type: 0x%02x\n", board_type, len); printf("%s: ", board_type); - for (i = 0; i < size_board; i++) { - if ((len & TYPE_CODE) == TYPE_CODE) { - printf("%c", data[i]); - } else { - /* other than language code (binary, BCD, - * ASCII 6 bit...) is not supported - */ - printf("%02x", data[i]); - } - } - printf("\n"); + i = 0; + str = (unsigned char *)get_fru_area_str(data, &i); + printf("%s\n", str); + free(str); + str = NULL; free(data); data = NULL; (*board_length) -= size_board; @@ -2772,14 +2774,15 @@ ipmi_ek_display_board_info_area(FILE *input_file, char *board_type, } printf("Additional Custom Mfg. length: 0x%02x\n", len); if ((size_board > 0) && (size_board < (*board_length))) { - unsigned char * additional_data = NULL; + unsigned char *additional_data, *str; unsigned int i = 0; - additional_data = malloc(size_board); + additional_data = malloc(size_board + 1); /* Make room for type/length field */ if (additional_data == NULL) { lprintf(LOG_ERR, "ipmitool: malloc failure"); return (size_t)(-1); } - ret = fread(additional_data, size_board, 1, input_file); + additional_data[0] = len; + ret = fread(additional_data + 1, size_board, 1, input_file); if ((ret != 1) || ferror(input_file)) { lprintf(LOG_ERR, "Invalid Additional Data!"); if (additional_data != NULL) { @@ -2788,14 +2791,15 @@ ipmi_ek_display_board_info_area(FILE *input_file, char *board_type, } goto out; } - printf("Additional Custom Mfg. Data: %02x", - additional_data[0]); - for (i = 1; i < size_board; i++) { - printf("-%02x", additional_data[i]); - } - printf("\n"); + printf("Additional Custom Mfg. Data: "); + i = 0; + str = (unsigned char *)get_fru_area_str(additional_data, &i); + printf("%s\n", str); + free(str); + str = NULL; free(additional_data); additional_data = NULL; + (*board_length) -= size_board; } else { commit 41fa699ae9480435cb888fa52405734e0ef6f349 Author: Alexander Amelkin <ale...@am...> Date: Tue Aug 11 02:28:19 2015 +0300 Add some more configure/build/editor byproducts to .gitignore diff --git a/.gitignore b/.gitignore index 5b8cb0a..58ca89e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,30 @@ +.deps +.libs +*.o +*.lo +*.la +*.*~ +Makefile Makefile.in aclocal.m4 autom4te.cache compile config.guess +config.h config.h.in +config.log +config.status config.sub configure depcomp install-sh ltmain.sh +libtool missing +stamp-h1 +control/ipmitool.spec +control/pkginfo +control/prototype +control/rpmmacros +src/ipmievd +src/ipmitool commit b35a6349087e64406ff6d4787c0612ae982ab4c4 Author: Alexander Amelkin <ale...@am...> Date: Tue Aug 11 02:52:33 2015 +0300 Add git hash and dirty mark to ipmitool version Replace the static 'csv' suffix with a short hash and a 'dirty' mark (when the tree is modified). When git is not available, '.git_snapshot' suffix will be used. diff --git a/configure.ac b/configure.ac index 896577b..f7676c9 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,8 @@ dnl dnl autoconf for ipmitool dnl -AC_INIT([ipmitool], [1.8.18-csv]) +m4_define([git_suffix], m4_esyscmd_s(git describe --always --dirty=wc 2>/dev/null || echo git_snapshot)) +AC_INIT([ipmitool], [1.8.18.git_suffix]) AC_CONFIG_SRCDIR([src/ipmitool.c]) AC_CANONICAL_SYSTEM AM_INIT_AUTOMAKE([foreign]) commit bc7d23761d07e67dad91c9d1dfb140c7d07c1a12 Author: Alexander Amelkin <ale...@am...> Date: Tue Aug 11 02:26:32 2015 +0300 Prevent autoreconf from complaining about missing NEWS diff --git a/configure.ac b/configure.ac index 88232a6..896577b 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ dnl AC_INIT([ipmitool], [1.8.18-csv]) AC_CONFIG_SRCDIR([src/ipmitool.c]) AC_CANONICAL_SYSTEM -AM_INIT_AUTOMAKE +AM_INIT_AUTOMAKE([foreign]) AM_CONFIG_HEADER(config.h) AC_PREREQ(2.50) AC_SUBST(ac_configure_args) commit e45dc6234bf887fa8356684c13f2468c3041c542 Author: Sergey Kleymenov <ser...@gm...> Date: Thu Mar 19 08:31:53 2015 +0300 Add bootstrap support for Mac diff --git a/bootstrap b/bootstrap index 6347427..c38b12b 100755 --- a/bootstrap +++ b/bootstrap @@ -31,7 +31,15 @@ # EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. aclocal -libtoolize --automake --copy + +case `uname` in + Darwin*) + glibtoolize --automake --copy + ;; + *) + libtoolize --automake --copy + ;; +esac autoheader automake --foreign --add-missing --copy ----------------------------------------------------------------------- Summary of changes: .gitignore | 18 ++++++++++++ bootstrap | 10 ++++++- configure.ac | 5 ++-- include/ipmitool/ipmi_fru.h | 1 + lib/ipmi_ekanalyzer.c | 69 +++++++++++++++++++++++++++++---------------- lib/ipmi_fru.c | 32 ++++++++++----------- 6 files changed, 91 insertions(+), 44 deletions(-) hooks/post-receive -- ipmitool |