[PATCH phosphor-host-ipmid] ipmid crashing with simplified VERSION_ID
OpenBMC Patches
openbmc-patches at stwcx.xyz
Sun May 1 07:40:36 AEST 2016
From: Chris Austen <austenc at us.ibm.com>
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.
---
apphandler.C | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/apphandler.C b/apphandler.C
index 53a83d3..80f239c 100644
--- a/apphandler.C
+++ b/apphandler.C
@@ -135,9 +135,18 @@ 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;
+
+ if (token) {
+ l = strlen(token);
+ if (l > 4)
+ l = 4;
+
+ // commit number we skip
+ token = strtok(NULL,".-");
+
+ } else {
+ l = 0;
+ }
memset(hexbyte,'0', 4);
memcpy(&hexbyte[4-l], token, l);
@@ -146,12 +155,11 @@ int convert_version(const char *p, rev_t *rev)
rev->d[2] = 0;
- // commit number we skip
- token = strtok(NULL,".-");
-
// 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[3] = (token != NULL) ? 1 : 0;
free(s);
return 0;
--
2.8.1
More information about the openbmc
mailing list