properly handle ilen = 0 case, which could lead to array underflow.

pointed out by Maxime Villard.
This commit is contained in:
mrg 2014-12-26 19:48:52 +00:00
parent 3d2a425be2
commit 7ce92dc944
1 changed files with 7 additions and 1 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: auth-bozo.c,v 1.14 2014/11/21 08:58:28 shm Exp $ */
/* $NetBSD: auth-bozo.c,v 1.15 2014/12/26 19:48:52 mrg Exp $ */
/* $eterna: auth-bozo.c,v 1.17 2011/11/18 09:21:15 mrg Exp $ */
@ -238,6 +238,12 @@ base64_decode(const unsigned char *in, size_t ilen, unsigned char *out,
unsigned char *cp;
size_t i;
if (ilen == 0) {
if (olen)
*out = '\0';
return 0;
}
cp = out;
for (i = 0; i < ilen; i += 4) {
if (cp + 3 > out + olen)