From fdb6f716744a2e43e086b786075907a8e880837c Mon Sep 17 00:00:00 2001 From: tedu <> Date: Sat, 19 Apr 2014 15:19:20 +0000 Subject: [PATCH] one small tweak to avoid ever going off the end of a string. --- src/lib/libc/crypt/bcrypt.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/libc/crypt/bcrypt.c b/src/lib/libc/crypt/bcrypt.c index a077c99d..7fcb2a51 100644 --- a/src/lib/libc/crypt/bcrypt.c +++ b/src/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 @@ -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);