scheduler: fix bugs related to changing code signing key

Two separate problems:
- a well-meaning change to remove compile warnings on 9 July 2013
  broke the reading of key files
- in the logic to scan old key files, we needed to use strip_whitespace()
  to remove the \n at end of file.
This commit is contained in:
David Anderson 2014-07-03 13:33:53 -07:00
parent 87d3cb5474
commit 5250f55c8a
2 changed files with 5 additions and 2 deletions

View File

@ -213,8 +213,7 @@ int scan_key_hex(FILE* f, KEY* key, int size) {
key->bits = num_bits;
len = size - sizeof(key->bits);
for (i=0; i<len; i++) {
fs = fscanf(f, "%2x", &n);
if (fs != 1) return ERR_NULL;
fscanf(f, "%2x", &n);
key->data[i] = n;
}
fs = fscanf(f, ".");

View File

@ -863,6 +863,7 @@ bool send_code_sign_key(char* code_sign_key) {
);
return false;
}
strip_whitespace(oldkey);
if (!strcmp(oldkey, g_request->code_sign_key)) {
// We've found the client's key.
// Get the signature for the new key.
@ -883,6 +884,9 @@ bool send_code_sign_key(char* code_sign_key) {
free(oldkey);
return false;
} else {
log_messages.printf(MSG_NORMAL,
"sending new code sign key and signature\n"
);
safe_strcpy(g_reply->code_sign_key, code_sign_key);
safe_strcpy(g_reply->code_sign_key_signature, signature);
free(signature);