1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Remove some spurious null pointer tests.

In load_openssh_new_key, ret->keyblob is never null any more: now that
it's a strbuf instead of a bare realloc()ed string, it's at worst an
_empty_ strbuf. Secondly, as Coverity pointed out, the null pointer
check was too late to do any good in the first place - the previous
clause of the same if condition would already have dereferenced it!

In test_mac in the auxiliary testsc program, there's no actual reason
I would ever have called it with null ssh_mac pointer - it would mean
'don't test anything'! Looks as if I just copy-pasted the MAC parts of
the cipher+MAC setup code in test_cipher.
This commit is contained in:
Simon Tatham 2019-05-05 08:20:24 +01:00
parent 64fdc85b2d
commit 0f6ce9bd01
2 changed files with 3 additions and 3 deletions

View File

@ -1166,7 +1166,7 @@ static struct openssh_new_key *load_openssh_new_key(const Filename *filename,
fclose(fp);
fp = NULL;
if (ret->keyblob->len == 0 || !ret->keyblob) {
if (ret->keyblob->len == 0) {
errmsg = "key body not present";
goto error;
}

View File

@ -1303,9 +1303,9 @@ static void test_mac(const ssh2_macalg *malg)
return;
}
uint8_t *mkey = malg ? snewn(malg->keylen, uint8_t) : NULL;
uint8_t *mkey = snewn(malg->keylen, uint8_t);
size_t datalen = 256;
size_t maclen = malg ? malg->len : 0;
size_t maclen = malg->len;
uint8_t *data = snewn(datalen + maclen, uint8_t);
/* Preliminarily key the MAC, to avoid the divergence of control