--- libraries/liblber/decode.c 2009/10/28 22:00:27 1.128 +++ libraries/liblber/decode.c 2009/11/04 10:17:03 1.129 @@ -1,5 +1,5 @@ /* decode.c - ber input decoding routines */ -/* $OpenLDAP: pkg/ldap/libraries/liblber/decode.c,v 1.127 2009/08/12 20:13:50 hallvard Exp $ */ +/* $OpenLDAP: pkg/ldap/libraries/liblber/decode.c,v 1.128 2009/10/28 22:00:27 hallvard Exp $ */ /* This work is part of OpenLDAP Software . * * Copyright 1998-2009 The OpenLDAP Foundation. @@ -481,7 +481,8 @@ ber_get_stringbv( BerElement *ber, struc tag = ber_skip_element( ber, bv ); if ( tag == LBER_DEFAULT || - (( option & LBER_BV_STRING ) && memchr( bv->bv_val, 0, bv->bv_len ))) + (( option & LBER_BV_STRING ) && + bv->bv_len && memchr( bv->bv_val, 0, bv->bv_len - 1 ))) { bv->bv_val = NULL; return LBER_DEFAULT; @@ -518,7 +519,9 @@ ber_get_stringbv_null( BerElement *ber, return tag; } - if (( option & LBER_BV_STRING ) && memchr( bv->bv_val, 0, bv->bv_len )) { + if (( option & LBER_BV_STRING ) && + memchr( bv->bv_val, 0, bv->bv_len - 1 )) + { bv->bv_val = NULL; return LBER_DEFAULT; }