Print this page
NEX-14547 Get UNIX group info. from AD/LDAP with partial RFC2307 schema
NEX-13132 smbd dumping core in nss_ldap.so.1`getbymember
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
   1 /*
   2  * Copyright 2001-2002 Sun Microsystems, Inc.  All rights reserved.
   3  * Use is subject to license terms.


   4  */
   5 
   6 #pragma ident   "%Z%%M% %I%     %E% SMI"
   7 
   8 
   9 /*
  10  * The contents of this file are subject to the Netscape Public
  11  * License Version 1.1 (the "License"); you may not use this file
  12  * except in compliance with the License. You may obtain a copy of
  13  * the License at http://www.mozilla.org/NPL/
  14  *
  15  * Software distributed under the License is distributed on an "AS
  16  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  17  * implied. See the License for the specific language governing
  18  * rights and limitations under the License.
  19  *
  20  * The Original Code is Mozilla Communicator client code, released
  21  * March 31, 1998.
  22  *
  23  * The Initial Developer of the Original Code is Netscape
  24  * Communications Corporation. Portions created by Netscape are
  25  * Copyright (C) 1998-1999 Netscape Communications Corporation. All
  26  * Rights Reserved.
  27  *
  28  * Contributor(s):


 788 
 789 
 790 /*
 791  * Undo in place both LDAPv2 (RFC-1960) and LDAPv3 (hexadecimal) escape
 792  * sequences within the null-terminated string 'val'.  The resulting value
 793  * may contain null characters.
 794  *
 795  * If 'val' contains invalid escape sequences we return -1.
 796  * Otherwise the length of the unescaped value is returned.
 797  */
 798 static int
 799 unescape_filterval( char *val )
 800 {
 801         int     escape, firstdigit, ival; 
 802         char    *s, *d;
 803 
 804         escape = 0;
 805         for ( s = d = val; *s; s++ ) {
 806                 if ( escape ) {
 807                         /*










 808                          * first try LDAPv3 escape (hexadecimal) sequence
 809                          */
 810                         if (( ival = hexchar2int( *s )) < 0 ) {
 811                                 if ( firstdigit ) {
 812                                         /*
 813                                          * LDAPv2 (RFC1960) escape sequence
 814                                          */
 815                                         *d++ = *s;
 816                                         escape = 0;
 817                                 } else {
 818                                         return(-1);
 819                                 }
 820                         }
 821                         if ( firstdigit ) {
 822                             *d = ( ival<<4 );
 823                             firstdigit = 0;
 824                         } else {
 825                             *d++ |= ival;
 826                             escape = 0;
 827                         }


   1 /*
   2  * Copyright 2001-2002 Sun Microsystems, Inc.  All rights reserved.
   3  * Use is subject to license terms.
   4  *
   5  * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
   6  */
   7 

   8 

   9 /*
  10  * The contents of this file are subject to the Netscape Public
  11  * License Version 1.1 (the "License"); you may not use this file
  12  * except in compliance with the License. You may obtain a copy of
  13  * the License at http://www.mozilla.org/NPL/
  14  *
  15  * Software distributed under the License is distributed on an "AS
  16  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  17  * implied. See the License for the specific language governing
  18  * rights and limitations under the License.
  19  *
  20  * The Original Code is Mozilla Communicator client code, released
  21  * March 31, 1998.
  22  *
  23  * The Initial Developer of the Original Code is Netscape
  24  * Communications Corporation. Portions created by Netscape are
  25  * Copyright (C) 1998-1999 Netscape Communications Corporation. All
  26  * Rights Reserved.
  27  *
  28  * Contributor(s):


 788 
 789 
 790 /*
 791  * Undo in place both LDAPv2 (RFC-1960) and LDAPv3 (hexadecimal) escape
 792  * sequences within the null-terminated string 'val'.  The resulting value
 793  * may contain null characters.
 794  *
 795  * If 'val' contains invalid escape sequences we return -1.
 796  * Otherwise the length of the unescaped value is returned.
 797  */
 798 static int
 799 unescape_filterval( char *val )
 800 {
 801         int     escape, firstdigit, ival; 
 802         char    *s, *d;
 803 
 804         escape = 0;
 805         for ( s = d = val; *s; s++ ) {
 806                 if ( escape ) {
 807                         /*
 808                          * need to leave escaped comma as-is, i.e.
 809                          * val="CN=Last\, First,OU=..."
 810                          */
 811                         if (*s == ',') {
 812                                 *d++ = '\\';
 813                                 *d++ = *s;
 814                                 escape = 0;
 815                                 continue;
 816                         }
 817                         /*
 818                          * first try LDAPv3 escape (hexadecimal) sequence
 819                          */
 820                         if (( ival = hexchar2int( *s )) < 0 ) {
 821                                 if ( firstdigit ) {
 822                                         /*
 823                                          * LDAPv2 (RFC1960) escape sequence
 824                                          */
 825                                         *d++ = *s;
 826                                         escape = 0;
 827                                 } else {
 828                                         return(-1);
 829                                 }
 830                         }
 831                         if ( firstdigit ) {
 832                             *d = ( ival<<4 );
 833                             firstdigit = 0;
 834                         } else {
 835                             *d++ |= ival;
 836                             escape = 0;
 837                         }