if (0 == strncmp(line, "-----END ", 9) &&
0 == strcmp(line+strlen(line)-16, "PRIVATE KEY-----")) {
sfree(line);
+ line = NULL;
break; /* done */
}
if ((p = strchr(line, ':')) != NULL) {
strip_crlf(line);
if (!strcmp(line, "---- END SSH2 ENCRYPTED PRIVATE KEY ----")) {
sfree(line);
+ line = NULL;
break; /* done */
}
if ((p = strchr(line, ':')) != NULL) {
answer = 1;
done:
- *comment = dupstr(key ? key->comment : "");
- smemclr(key->keyblob, key->keyblob_size);
- sfree(key->keyblob);
- smemclr(key, sizeof(*key));
- sfree(key);
+ if (key) {
+ *comment = dupstr(key->comment);
+ smemclr(key->keyblob, key->keyblob_size);
+ sfree(key->keyblob);
+ smemclr(key, sizeof(*key));
+ sfree(key);
+ } else {
+ *comment = dupstr("");
+ }
return answer;
}
pos += put_mp(blob+pos, p.start, p.bytes);
pos += put_mp(blob+pos, u.start, u.bytes);
privlen = pos - publen;
- } else if (type == DSA) {
+ } else {
struct mpint_pos p, q, g, x, y;
int pos = 4;
+
+ assert(type == DSA); /* the only other option from the if above */
+
if (GET_32BIT(ciphertext) != 0) {
errmsg = "predefined DSA parameters not supported";
goto error;
publen = pos;
pos += put_mp(blob+pos, x.start, x.bytes);
privlen = pos - publen;
- } else
- return NULL;
+ }
assert(privlen > 0); /* should have bombed by now if not */