]> git.sur5r.net Git - openldap/blobdiff - libraries/liblber/decode.c
Merge remote-tracking branch 'origin/mdb.master' into OPENLDAP_REL_ENG_2_4
[openldap] / libraries / liblber / decode.c
index 151a188f6ff63dcfc487dbe082cda12f919ac2b8..60a70a5013a126b3a040f71e8526f1e676814ec8 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2009 The OpenLDAP Foundation.
+ * Copyright 1998-2013 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -481,7 +481,8 @@ ber_get_stringbv( BerElement *ber, struct berval *bv, int option )
 
        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, struct berval *bv, int option )
                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;
        }