]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/filter.c
ITS#5300
[openldap] / libraries / libldap / filter.c
index 673147225af9f408813780062f7f859b6a3e7a6c..3ad77c4fdb8799d7bcfb479674cf1f0eb99e8b14 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2006 The OpenLDAP Foundation.
+ * Copyright 1998-2007 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -422,6 +422,10 @@ ldap_pvt_put_filter( BerElement *ber, const char *str_in )
                                parens--;
                                break;
 
+                       case '(':
+                               rc = -1;
+                               goto done;
+
                        default:
                                Debug( LDAP_DEBUG_TRACE, "put_filter: simple\n",
                                    0, 0, 0 );
@@ -494,9 +498,11 @@ ldap_pvt_put_filter( BerElement *ber, const char *str_in )
                        str = next;
                        break;
                }
+               if ( !parens )
+                       break;
        }
 
-       rc = parens ? -1 : 0;
+       rc = ( parens || *str ) ? -1 : 0;
 
 done:
        LDAP_FREE( freeme );
@@ -745,10 +751,12 @@ put_substring_filter( BerElement *ber, char *type, char *val )
                        }
                }
 
-               if ( *val != '\0' || ftype == LDAP_SUBSTRING_ANY ) {
+               if ( *val == '\0' ) {
+                       return -1;
+               } else {
                        ber_slen_t len = ldap_pvt_filter_value_unescape( val );
 
-                       if ( len < 0  ) {
+                       if ( len <= 0  ) {
                                return -1;
                        }