Print this page
3285 memory leaks in libsldap


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  * Copyright 2012 Milan Jurik. All rights reserved.

  25  */
  26 
  27 #define __STANDALONE_MODULE__
  28 
  29 #include <stdio.h>
  30 #include <sys/types.h>
  31 #include <stdlib.h>
  32 #include <libintl.h>
  33 #include <string.h>
  34 #include <ctype.h>
  35 
  36 #include <sys/stat.h>
  37 #include <fcntl.h>
  38 #include <unistd.h>
  39 #include <syslog.h>
  40 #include <locale.h>
  41 #include <errno.h>
  42 #include <sys/time.h>
  43 
  44 #include <arpa/inet.h>


1433                  * not comply with the LDAP v3 protocol.
1434                  */
1435                 (void) ldap_get_option(session->ld,
1436                     LDAP_OPT_ERROR_NUMBER,
1437                     &ldaperrno);
1438                 (void) snprintf(errmsg,
1439                     sizeof (errmsg),
1440                     gettext(ldap_err2string(ldaperrno)));
1441                 MKERROR(LOG_ERR,
1442                     *errorp,
1443                     NS_LDAP_OP_FAILED,
1444                     strdup(errmsg),
1445                     NS_LDAP_MEMORY);
1446 
1447                 if (resultMsg) {
1448                         (void) ldap_msgfree(resultMsg);
1449                         resultMsg = NULL;
1450                 }
1451 
1452                 __s_api_conn_user_free(cu);

1453                 return (NS_LDAP_OP_FAILED);
1454         }
1455         __s_api_conn_user_free(cu);
1456 
1457         ret_code = convert_to_door_line(session->ld,
1458             resultMsg,
1459             INCLUDE_ATTR_NAMES,
1460             NOT_PROFILE,
1461             root_dse);
1462         if (ret_code == NS_LDAP_NOTFOUND) {
1463                 (void) snprintf(errmsg,
1464                     sizeof (errmsg),
1465                     gettext("No root DSE data "
1466                     "for server %s returned."),
1467                     server_addr);
1468                 MKERROR(LOG_ERR,
1469                     *errorp,
1470                     NS_LDAP_NOTFOUND,
1471                     strdup(errmsg),
1472                     NS_LDAP_MEMORY);




   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  * Copyright 2012 Milan Jurik. All rights reserved.
  25  * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
  26  */
  27 
  28 #define __STANDALONE_MODULE__
  29 
  30 #include <stdio.h>
  31 #include <sys/types.h>
  32 #include <stdlib.h>
  33 #include <libintl.h>
  34 #include <string.h>
  35 #include <ctype.h>
  36 
  37 #include <sys/stat.h>
  38 #include <fcntl.h>
  39 #include <unistd.h>
  40 #include <syslog.h>
  41 #include <locale.h>
  42 #include <errno.h>
  43 #include <sys/time.h>
  44 
  45 #include <arpa/inet.h>


1434                  * not comply with the LDAP v3 protocol.
1435                  */
1436                 (void) ldap_get_option(session->ld,
1437                     LDAP_OPT_ERROR_NUMBER,
1438                     &ldaperrno);
1439                 (void) snprintf(errmsg,
1440                     sizeof (errmsg),
1441                     gettext(ldap_err2string(ldaperrno)));
1442                 MKERROR(LOG_ERR,
1443                     *errorp,
1444                     NS_LDAP_OP_FAILED,
1445                     strdup(errmsg),
1446                     NS_LDAP_MEMORY);
1447 
1448                 if (resultMsg) {
1449                         (void) ldap_msgfree(resultMsg);
1450                         resultMsg = NULL;
1451                 }
1452 
1453                 __s_api_conn_user_free(cu);
1454                 DropConnection(sessionId, NS_LDAP_NEW_CONN);
1455                 return (NS_LDAP_OP_FAILED);
1456         }
1457         __s_api_conn_user_free(cu);
1458 
1459         ret_code = convert_to_door_line(session->ld,
1460             resultMsg,
1461             INCLUDE_ATTR_NAMES,
1462             NOT_PROFILE,
1463             root_dse);
1464         if (ret_code == NS_LDAP_NOTFOUND) {
1465                 (void) snprintf(errmsg,
1466                     sizeof (errmsg),
1467                     gettext("No root DSE data "
1468                     "for server %s returned."),
1469                     server_addr);
1470                 MKERROR(LOG_ERR,
1471                     *errorp,
1472                     NS_LDAP_NOTFOUND,
1473                     strdup(errmsg),
1474                     NS_LDAP_MEMORY);