Skip to content

Commit

Permalink
ipmid crashing with simplified VERSION_ID
Browse files Browse the repository at this point in the history
if the VERSION_ID is v0.1 instead of v0.1-1 then the code will crash.  The fix is to always check
for a NULL token each time.

Change ipmitool output to reflect hex value

VERSION_ID is equal to v0.6-36-gece9f78-dirty
I was forcing the '36' to be shown as 36.  Turns out
that the ipmitool prepends the "Aux" section with a
'0x' indicating the value is in hex.  So Rather then
it show up as 0x36  I made it actually be 0x24.

root@barreleye:~# ./ipmitool -I dbus mc info
IPMI GROUP EXTENTIONS
IPMI GROUP EXTENTIONS
Device ID                 : 0
Device Revision           : 0
Firmware Revision         : 0.06
IPMI Version              : 2.0
Manufacturer ID           : 42817
Manufacturer Name         : Unknown (0xA741)
Product ID                : 16451 (0x4043)
Product Name              : Unknown (0x4043)
Device Available          : yes
Provides Device SDRs      : no
Additional Device Support :
    Sensor Device
    SEL Device
    FRU Inventory Device
Aux Firmware Rev Info     :
    0x00
    0x24   <---- is decimal 36
    0x01
    0x00
root@barreleye:~#
  • Loading branch information
Chris Austen committed May 3, 2016
1 parent 2bcf128 commit 176c965
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions apphandler.C
Expand Up @@ -100,7 +100,7 @@ typedef struct
{
char major;
char minor;
uint8_t d[4];
uint16_t d[2];
} rev_t;


Expand All @@ -119,6 +119,7 @@ int convert_version(const char *p, rev_t *rev)
char *s, *token;
char hexbyte[5];
int l;
uint16_t commits;

if (*p != 'v')
return -1;
Expand All @@ -135,23 +136,23 @@ int convert_version(const char *p, rev_t *rev)
// Capture the number of commits on top of the minor tag.
// I'm using BE format like the ipmi spec asked for
token = strtok(NULL,".-");
l = strlen(token);
if (l > 4)
l = 4;

memset(hexbyte,'0', 4);
memcpy(&hexbyte[4-l], token, l);
sscanf(&hexbyte[0], "%2hhX", &rev->d[0]);
sscanf(&hexbyte[2], "%2hhX", &rev->d[1]);
if (token) {
commits = (int16_t) atoi(token);
rev->d[0] = (commits>>8) | (commits<<8);

rev->d[2] = 0;
// commit number we skip
token = strtok(NULL,".-");

// commit number we skip
token = strtok(NULL,".-");
} else {
rev->d[0] = 0;
}

// Any value of the optional parameter forces it to 1
token = strtok(NULL,".-");
rev->d[3] = (token != NULL) ? 1 : 0;
if (token)
token = strtok(NULL,".-");

rev->d[1] = (token != NULL) ? 1 : 0;

free(s);
return 0;
Expand Down

0 comments on commit 176c965

Please sign in to comment.