summaryrefslogtreecommitdiff
path: root/util/ifruset.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2018-08-01 11:11:19 +0200
committerJörg Frings-Fürst <debian@jff.email>2018-08-01 11:11:19 +0200
commit02dc10f02447b6f35224fec2b2280a35022bc37b (patch)
tree20e723b2017ab3b74bf44a22be1dfbc1458d3e8f /util/ifruset.c
parentc7d4db3862a24474655a43c98572e82503d9fa6b (diff)
parent9bf6d68108836bfbcc5296a50a48cfd6af9151b7 (diff)
Update upstream source from tag 'upstream/3.1.2'
Update to upstream version '3.1.2' with Debian dir 2863fdfb0e9680d5192c60db9601d0f03050edb0
Diffstat (limited to 'util/ifruset.c')
-rw-r--r--util/ifruset.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/util/ifruset.c b/util/ifruset.c
index b2f8b66..2d7617b 100644
--- a/util/ifruset.c
+++ b/util/ifruset.c
@@ -109,7 +109,7 @@ extern void fmt_time(time_t etime, char *buf, int bufsz); /*see ievents.c*/
extern char * progver; /*from ipmiutil.c*/
static char *progname = "ipmiutil fruset";
#else
-static char * progver = "3.08";
+static char * progver = "3.12";
static char *progname = "ifruset";
#endif
static char fdebug = 0;
@@ -711,10 +711,14 @@ show_fru(uchar sa, uchar frudev, uchar frutype)
*/
pfru = &frubuf[0];
sz = 8; /*minimum for common header*/
- for (i = 1; i < 6; i++) /* walk thru offsets */
- if (frubuf[i] != 0) sz = frubuf[i] * 8;
- if (sz > 8) /* if have at least one section */
- sz += frubuf[sz+1] * 8; /* add length of last section */
+ for (i = 1; i < 6; i++) { /* walk thru offsets */
+ if (frubuf[i] != 0) sz = frubuf[i] * 8;
+ }
+ if (sz > 8) { /* if have at least one section */
+ if (frubuf[5] != 0) j = 5 + frubuf[sz+2]; /*if multi-record area*/
+ else j = frubuf[sz+1] * 8; /* else add length of last section */
+ sz += j;
+ }
/* Now, sz = size used, sfru = total available size */
if (sz > sfru) {
if (fdebug) {
@@ -752,10 +756,11 @@ show_fru(uchar sa, uchar frudev, uchar frutype)
mlen = 0;
if (moff > 0) {
for (i = moff; i < sfru; ) {
- j = 5 + frubuf[i+2];
+ if (frubuf[i] == 0 && frubuf[i+2] == 0) break; /*type/len invalid*/
+ j = 5 + frubuf[i+2];
mlen += j;
if (frubuf[i+1] & 0x80) break;
- i += j;
+ i += j;
}
}
@@ -897,8 +902,9 @@ show_fru(uchar sa, uchar frudev, uchar frutype)
j = moff;
for (i = 0; j < sz; i++)
{
+ if (pfru[0] == 0 && pfru[2] == 0) break; /*type/len invalid*/
n = pfru[2]; /* len of this record */
- show_fru_multi(devstr,i,pfru[0],&pfru[5],n);
+ show_fru_multi(devstr,i,pfru[0],&pfru[5],n);
j += (5 + n);
if (pfru[1] & 0x80) j = sz; /*0x80 = end of list*/
pfru += (5 + n);
@@ -1367,7 +1373,7 @@ main(int argc, char **argv)
parse_lan_options(c,optarg,fdebug);
break;
default:
- printf("Usage: %s [-bcimx -unpvsafo -NUPREFTVY]\n",progname);
+ printf("Usage: %s [-bcimxy -unpvsafo -NUPREFTVY]\n",progname);
printf(" -u manu Sets Product Manufacturer (0)\n");
printf(" -n name Sets Product Name (1)\n");
printf(" -p part Sets Product Part Number (2)\n");
@@ -1382,8 +1388,9 @@ main(int argc, char **argv)
printf(" -d Dump FRU to a file\n");
printf(" -r Restore FRU from a file\n");
printf(" -i 00 Get/Set a specific FRU ID\n");
- printf(" -m002000 specific MC (bus 00,sa 20,lun 00)\n");
+ printf(" -m002000 specific MC (bus 00,sa 20,lun 00)\n");
printf(" -x Display extra debug messages\n");
+ printf(" -y Ignore the check for FRU size overflow\n");
print_lan_opt_usage(0);
ret = ERR_USAGE;
goto do_exit;
@@ -1567,7 +1574,11 @@ main(int argc, char **argv)
if (fdump && ret == 0) {
/* Dump FRU to a binary file */
+#ifdef WIN32
+ fp = fopen(binfile,"wb");
+#else
fp = fopen(binfile,"w");
+#endif
if (fp == NULL) {
ret = get_LastError();
printf("Cannot open file %s, error %d\n",binfile,ret);
@@ -1583,9 +1594,13 @@ main(int argc, char **argv)
} else if (frestore) {
uchar cksum;
/* Restore FRU from a binary file */
+#ifdef WIN32
+ fp = fopen(binfile,"rb");
+#else
fp = fopen(binfile,"r");
+#endif
if (fp == NULL) {
- ret = get_LastError();
+ ret = get_LastError();
printf("Cannot open file %s, error %d\n",binfile,ret);
} else {
ret = 0;