From 7398dfa3fccf9781d81d4cbc990baa7602b50398 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 13 Sep 2022 15:48:11 +0100 Subject: [PATCH] Remove a pointless allocation. The char buffer 'blob' allocated in read_blob was never actually used for anything, so there was no need to allocate it - and also no need for the assert() just before it, which was added in commit 63a58759b5c0c11 to be extra safe against integer overflow when computing the buffer size. I feel a bit silly for having added that assertion in the first place rather than removing the allocation it was protecting! It was unnecessary even then, and I completely failed to notice :-) (cherry picked from commit c780cffb7a6f1c972f5629e6e4976c5616ca0df3) --- sshpubk.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/sshpubk.c b/sshpubk.c index 0648b4c4..cc44a9b4 100644 --- a/sshpubk.c +++ b/sshpubk.c @@ -516,24 +516,18 @@ static char *read_body(BinarySource *src) static bool read_blob(BinarySource *src, int nlines, BinarySink *bs) { - unsigned char *blob; char *line; int linelen; int i, j, k; /* We expect at most 64 base64 characters, ie 48 real bytes, per line. */ - assert(nlines < MAX_KEY_BLOB_LINES); - blob = snewn(48 * nlines, unsigned char); for (i = 0; i < nlines; i++) { line = read_body(src); - if (!line) { - sfree(blob); + if (!line) return false; - } linelen = strlen(line); if (linelen % 4 != 0 || linelen > 64) { - sfree(blob); sfree(line); return false; } @@ -542,14 +536,12 @@ static bool read_blob(BinarySource *src, int nlines, BinarySink *bs) k = base64_decode_atom(line + j, decoded); if (!k) { sfree(line); - sfree(blob); return false; } put_data(bs, decoded, k); } sfree(line); } - sfree(blob); return true; }