summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2014-04-19 15:19:20 +0000
committertedu <tedu@openbsd.org>2014-04-19 15:19:20 +0000
commit7b5a73602e85375c90638c568c621a9b1362cf11 (patch)
tree9101433c5d51540afa44d82759a0cd2e9138ad3e /lib/libc
parentimproved checking for invalid hashes. from solar designer (diff)
downloadwireguard-openbsd-7b5a73602e85375c90638c568c621a9b1362cf11.tar.xz
wireguard-openbsd-7b5a73602e85375c90638c568c621a9b1362cf11.zip
one small tweak to avoid ever going off the end of a string.
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/crypt/bcrypt.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/libc/crypt/bcrypt.c b/lib/libc/crypt/bcrypt.c
index a077c99de57..7fcb2a51874 100644
--- a/lib/libc/crypt/bcrypt.c
+++ b/lib/libc/crypt/bcrypt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcrypt.c,v 1.38 2014/04/19 15:17:59 tedu Exp $ */
+/* $OpenBSD: bcrypt.c,v 1.39 2014/04/19 15:19:20 tedu Exp $ */
/*
* Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
@@ -276,10 +276,12 @@ decode_base64(u_int8_t *buffer, size_t len, const char *b64data)
while (bp < buffer + len) {
c1 = CHAR64(*p);
- c2 = CHAR64(*(p + 1));
-
/* Invalid data */
- if (c1 == 255 || c2 == 255)
+ if (c1 == 255)
+ return -1;
+
+ c2 = CHAR64(*(p + 1));
+ if (c2 == 255)
return -1;
*bp++ = (c1 << 2) | ((c2 & 0x30) >> 4);