Commit 724e75ee authored by Cody Cutler's avatar Cody Cutler Committed by Mike Hibler

Choose sensible size for pcomp in secure state verification

And a couple of error-printf bugfixes
(cherry picked from commit e31153aee1c7da2bb92d8528f951b34b952d0eda)
parent e280ae1d
...@@ -5195,7 +5195,7 @@ COMMAND_PROTOTYPE(dosecurestate) ...@@ -5195,7 +5195,7 @@ COMMAND_PROTOTYPE(dosecurestate)
{ {
char newstate[128]; /* More then we will ever need */ char newstate[128]; /* More then we will ever need */
char quote[1024]; char quote[1024];
char pcomp[256]; char pcomp[1024];
unsigned char quote_bin[256]; unsigned char quote_bin[256];
unsigned char pcomp_bin[128]; unsigned char pcomp_bin[128];
ssize_t pcomplen, quotelen; ssize_t pcomplen, quotelen;
...@@ -5234,10 +5234,11 @@ COMMAND_PROTOTYPE(dosecurestate) ...@@ -5234,10 +5234,11 @@ COMMAND_PROTOTYPE(dosecurestate)
* Have to covert the hex representations of quote and pcomp into * Have to covert the hex representations of quote and pcomp into
* simple binary. * simple binary.
*/ */
if ((strlen(quote) % 2) != 0) { if ((strlen(quote) % 2) != 0) {
error("SECURESTATE: %s: Malformed quote: odd length\n"); error("SECURESTATE: %s: Malformed quote: odd length\n",
return 1; reqp->nodeid);
} return 1;
}
quotelen = strlen(quote)/2; quotelen = strlen(quote)/2;
printf("quotelen is %d\n",quotelen); printf("quotelen is %d\n",quotelen);
for (i = 0; i < quotelen; i++) { for (i = 0; i < quotelen; i++) {
...@@ -5249,10 +5250,11 @@ COMMAND_PROTOTYPE(dosecurestate) ...@@ -5249,10 +5250,11 @@ COMMAND_PROTOTYPE(dosecurestate)
quote_bin[i] = hextochar(&quote[i * 2]); quote_bin[i] = hextochar(&quote[i * 2]);
} }
if ((strlen(pcomp) % 2) != 0) { if ((strlen(pcomp) % 2) != 0) {
error("SECURESTATE: %s: Malformed pcomp: odd length\n"); error("SECURESTATE: %s: Malformed pcomp: odd length\n",
return 1; reqp->nodeid);
} return 1;
}
pcomplen = strlen(pcomp)/2; pcomplen = strlen(pcomp)/2;
for (i = 0; i < pcomplen; i++) { for (i = 0; i < pcomplen; i++) {
if (!ishex(pcomp[i * 2]) || !ishex(pcomp[i * 2 + 1])) { if (!ishex(pcomp[i * 2]) || !ishex(pcomp[i * 2 + 1])) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment