summaryrefslogtreecommitdiff
path: root/sshbuf-misc.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2019-07-18 13:26:00 +0000
committerDamien Miller <djm@mindrot.org>2019-07-18 23:27:09 +1000
commited46a0c0705895834d3f47a46faa89c2a71b760a (patch)
treeb0dfbb1e56a6e15db77321222112e12774b8f0ba /sshbuf-misc.c
parenta192021fedead23c375077f92346336d531f8cad (diff)
downloadopenssh-git-ed46a0c0705895834d3f47a46faa89c2a71b760a.tar.gz
upstream: fix off-by-one in sshbuf_dtob64() base64 wrapping that could
cause extra newlines to be appended at the end of the base64 text (ugly, but harmless). Found and fixed by Sebastian Kinne OpenBSD-Commit-ID: 9fe290bd68f706ed8f986a7704ca5a2bd32d7b68
Diffstat (limited to 'sshbuf-misc.c')
-rw-r--r--sshbuf-misc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sshbuf-misc.c b/sshbuf-misc.c
index 4a4985fd..417ab593 100644
--- a/sshbuf-misc.c
+++ b/sshbuf-misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshbuf-misc.c,v 1.9 2019/07/16 13:18:39 djm Exp $ */
+/* $OpenBSD: sshbuf-misc.c,v 1.10 2019/07/18 13:26:00 djm Exp $ */
/*
* Copyright (c) 2011 Damien Miller
*
@@ -114,7 +114,7 @@ sshbuf_dtob64(const struct sshbuf *d, struct sshbuf *b64, int wrap)
if (i % 70 == 69 && (r = sshbuf_put_u8(b64, '\n')) != 0)
goto fail;
}
- if (i % 70 != 69 && (r = sshbuf_put_u8(b64, '\n')) != 0)
+ if ((i - 1) % 70 != 69 && (r = sshbuf_put_u8(b64, '\n')) != 0)
goto fail;
} else {
if ((r = sshbuf_put(b64, s, strlen(s))) != 0)