Browse Source

one small tweak to avoid ever going off the end of a string.

OPENBSD_5_6
tedu 10 years ago
parent
commit
fdb6f71674
1 changed files with 6 additions and 4 deletions
  1. +6
    -4
      src/lib/libc/crypt/bcrypt.c

+ 6
- 4
src/lib/libc/crypt/bcrypt.c View File

@ -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);


Loading…
Cancel
Save