[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-httpd-dev
Subject:    PATCH: incorrect use of an enum in util_ldap.h struct
From:       "David Jones" <oscaremma () gmail ! com>
Date:       2007-02-23 19:03:16
Message-ID: 3ce0569d0702231103u2cf4dc5fua6c6d9e61f2639 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


In util_ldap.h there is a use of an enum in util_ldap.h (struct
util_ldap_connection_t) with the assumption that it is of length int.
Similar enum in aaa/mod_authnz_ldap.c.
As the size of an enum is indeterminate  this call in util_ldap.c may/may
not get a valid value based on how the compiler handles it:
           ldap_set_option(ldc->ldap, LDAP_OPT_DEREF, &(ldc->deref));

By changing the stuct to use an int type for deref instead of deref_options
we guarantee valid behavior.


Index: httpd-trunk/include/util_ldap.h
===================================================================
--- httpd-trunk/include/util_ldap.h    (revision 494665)
+++ httpd-trunk/include/util_ldap.h    (working copy)
@@ -92,7 +92,7 @@

     const char *host;                   /* Name of the LDAP server (or
space separated list) */
     int port;                           /* Port of the LDAP server */
-    deref_options deref;                /* how to handle alias dereferening
*/
+    int deref;                          /* how to handle alias dereferening
*/

     const char *binddn;                 /* DN to bind to server (can be
NULL) */
     const char *bindpw;                 /* Password to bind to server (can
be NULL) */
@@ -202,11 +202,11 @@
  *      use this connection while it is busy. Once you are finished with a
connection,
  *      apr_ldap_connection_close() must be called to release this
connection.
  * @deffunc util_ldap_connection_t *util_ldap_connection_find(request_rec
*r, const char *host, int port,
- *                                                           const char
*binddn, const char *bindpw, deref_options deref,
+ *                                                           const char
*binddn, const char *bindpw, int deref,
  *                                                           int
netscapessl, int starttls)
  */
 APR_DECLARE_OPTIONAL_FN(util_ldap_connection_t
*,uldap_connection_find,(request_rec *r, const char *host, int port,
-                                                  const char *binddn, const
char *bindpw, deref_options deref,
+                                                  const char *binddn, const
char *bindpw, int deref,
                                                   int secure));

 /**
Index: httpd-trunk/modules/ldap/util_ldap.c
===================================================================
--- httpd-trunk/modules/ldap/util_ldap.c    (revision 510991)
+++ httpd-trunk/modules/ldap/util_ldap.c    (working copy)
@@ -443,7 +443,7 @@
             uldap_connection_find(request_rec *r,
                                   const char *host, int port,
                                   const char *binddn, const char *bindpw,
-                                  deref_options deref, int secure)
+                                  int deref, int secure)
 {
     struct util_ldap_connection_t *l, *p; /* To traverse the linked list */
     int secureflag = secure;
Index: httpd-trunk/modules/aaa/mod_authnz_ldap.c
===================================================================
--- httpd-trunk/modules/aaa/mod_authnz_ldap.c    (revision 494665)
+++ httpd-trunk/modules/aaa/mod_authnz_ldap.c    (working copy)
@@ -57,7 +57,7 @@
     char **attributes;              /* Array of all the attributes to
return */
     int scope;                      /* Scope of the search */
     char *filter;                   /* Filter to further limit the search
*/
-    deref_options deref;            /* how to handle alias dereferening */
+    int deref;                      /* how to handle alias dereferening */
     char *binddn;                   /* DN to bind to server (can be NULL)
*/
     char *bindpw;                   /* Password to bind to server (can be
NULL) */

[Attachment #5 (text/html)]

In util_ldap.h there is a use of an enum in util_ldap.h (struct
util_ldap_connection_t) with the assumption that it is of length int. <br>Similar \
enum in aaa/mod_authnz_ldap.c.<br>As the size of an enum is indeterminate&nbsp; this \
call in util_ldap.c may/may not get a valid value based on how the compiler handles \
it: <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
ldap_set_option(ldc-&gt;ldap, LDAP_OPT_DEREF, &amp;(ldc-&gt;deref));<br><br>By \
changing the stuct to use an int type for deref instead of deref_options we guarantee \
valid behavior.<br><br><br>Index: httpd-trunk/include/util_ldap.h \
<br>==============================<div>=====================================<br>--- \
httpd-trunk/include/util_ldap.h&nbsp;&nbsp;&nbsp; (revision 494665)<br>+++ \
httpd-trunk/include/util_ldap.h&nbsp;&nbsp;&nbsp; (working copy)<br>@@ -92,7 +92,7 @@ \
<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp; const char \
*host;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
/* Name of the LDAP server (or space separated list) */ <br>&nbsp;&nbsp;&nbsp;&nbsp; \
int port;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
/* Port of the LDAP server */<br>-&nbsp;&nbsp;&nbsp; deref_options \
deref;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
/* how to handle alias dereferening */<br>+&nbsp;&nbsp;&nbsp; int \
deref;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
/* how to handle alias dereferening */ <br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp; const \
char *binddn;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
/* DN to bind to server (can be NULL) */<br>&nbsp;&nbsp;&nbsp;&nbsp; const char \
*bindpw;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
/* Password to bind to server (can be NULL) */<br>@@ -202,11 +202,11 @@<br>&nbsp; \
*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; use this connection while it is busy. Once you are \
finished with a connection, <br>&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
apr_ldap_connection_close() must be called to release this connection.<br>&nbsp; * \
@deffunc util_ldap_connection_t *util_ldap_connection_find(request_rec *r, const char \
*host, int port,<br>- \
*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& \
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb \
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp \
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
const char *binddn, const char *bindpw, deref_options deref, <br>+ \
*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& \
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb \
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp \
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
const char *binddn, const char *bindpw, int deref, <br>&nbsp; \
*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& \
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb \
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp \
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
int netscapessl, int starttls)<br>&nbsp; */ \
<br>&nbsp;APR_DECLARE_OPTIONAL_FN(util_ldap_connection_t \
*,uldap_connection_find,(request_rec *r, const char *host, int \
port,<br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs \
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
const char *binddn, const char *bindpw, deref_options deref, \
<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb \
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp \
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
const char *binddn, const char *bindpw, int \
deref,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs \
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
int secure));<br>&nbsp;<br>&nbsp;/**<br>Index: httpd-trunk/modules/ldap/util_ldap.c \
<br>===================================================================<br>--- \
httpd-trunk/modules/ldap/util_ldap.c&nbsp;&nbsp;&nbsp; (revision 510991)<br>+++ \
httpd-trunk/modules/ldap/util_ldap.c&nbsp;&nbsp;&nbsp; (working copy)<br>@@ -443,7 \
+443,7 @@ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
uldap_connection_find(request_rec \
*r,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& \
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
const char *host, int \
port,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp \
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
const char *binddn, const char \
*bindpw,<br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& \
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
deref_options deref, int secure) \
<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb \
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
int deref, int secure)<br>&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp; struct \
util_ldap_connection_t *l, *p; /* To traverse the linked list \
*/<br>&nbsp;&nbsp;&nbsp;&nbsp; int secureflag = secure;<br>Index: \
httpd-trunk/modules/aaa/mod_authnz_ldap.c \
<br>===================================================================<br>--- \
httpd-trunk/modules/aaa/mod_authnz_ldap.c&nbsp;&nbsp;&nbsp; (revision 494665)<br>+++ \
httpd-trunk/modules/aaa/mod_authnz_ldap.c&nbsp;&nbsp;&nbsp; (working copy)<br>@@ \
-57,7 +57,7 @@ <br>&nbsp;&nbsp;&nbsp;&nbsp; char \
**attributes;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
/* Array of all the attributes to return */<br>&nbsp;&nbsp;&nbsp;&nbsp; int \
scope;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
/* Scope of the search */<br>&nbsp;&nbsp;&nbsp;&nbsp; char \
*filter;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
/* Filter to further limit the search&nbsp; */ <br>-&nbsp;&nbsp;&nbsp; deref_options \
deref;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* how to \
handle alias dereferening */<br>+&nbsp;&nbsp;&nbsp; int \
deref;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
/* how to handle alias dereferening */<br>&nbsp;&nbsp;&nbsp;&nbsp; char \
*binddn;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
/* DN to bind to server (can be NULL) */ <br>&nbsp;&nbsp;&nbsp;&nbsp; char \
*bindpw;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
/* Password to bind to server (can be NULL) */</div>


["deref01.patch" (application/octet-stream)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic