]> git.sur5r.net Git - openldap/commitdiff
reimplementation of sb_max_incoming
authorKurt Zeilenga <kurt@openldap.org>
Fri, 4 May 2001 21:15:09 +0000 (21:15 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Fri, 4 May 2001 21:15:09 +0000 (21:15 +0000)
include/lber.h
include/ldap.h
libraries/liblber/io.c
libraries/liblber/lber-int.h
libraries/liblber/sockbuf.c

index e89d500473301db4488459aef0f0b5c5a4224721..64ecb23e18a77d658d5f31c66722b8a10563243a 100644 (file)
@@ -131,8 +131,10 @@ typedef struct lber_memory_fns {
 #define LBER_SB_OPT_DRAIN              10
 #define LBER_SB_OPT_NEEDS_READ         11
 #define LBER_SB_OPT_NEEDS_WRITE                12
+#define LBER_SB_OPT_GET_MAX_INCOMING 13
+#define LBER_SB_OPT_SET_MAX_INCOMING 14
 /* Largest option used by the library */
-#define LBER_SB_OPT_OPT_MAX            12
+#define LBER_SB_OPT_OPT_MAX            14
 
 /* LBER IO operations stacking levels */
 #define LBER_SBIOD_LEVEL_PROVIDER      10
index 09f578917560e0065ae590059355a7227288f49e..241ec138d1273c9308297f300e5ed720cfea036b 100644 (file)
@@ -285,6 +285,7 @@ typedef struct ldapcontrol {
 
 /* sasl methods */
 #define LDAP_SASL_SIMPLE               ((char*)0)
+#define LDAP_SASL_NULL                 ("")
 
 
 /* authentication methods available */
index 71a2feb1e6334c071bf8cd636ea125625e887daf..36e43311047f8ac528121a98f518c67cc82aa127 100644 (file)
@@ -546,10 +546,15 @@ get_lenbyte:
 
 fill_buffer:   
        /* now fill the buffer. */
-       if (ber->ber_len==0) {
+
+       /* make sure length is reasonable */
+       if ( ber->ber_len == 0 ||
+               ( sb->sb_max_incoming && ber->ber_len > sb->sb_max_incoming ))
+       {
                errno = ERANGE;
                return LBER_DEFAULT;
        }
+
        if (ber->ber_buf==NULL) {
                ber->ber_buf = (char *) LBER_MALLOC( ber->ber_len );
                if (ber->ber_buf==NULL) {
index 78cac6d0a08ac96c5366ce2fe389f454a381a85a..bb2ade16fcab98f3f1dcc7879b1dd04fb1756c69 100644 (file)
@@ -87,6 +87,7 @@ struct sockbuf {
        ber_socket_t            sb_fd;
        unsigned int            sb_trans_needs_read:1;
        unsigned int            sb_trans_needs_write:1;
+       ber_len_t                       sb_max_incoming;
 };
 
 #define SOCKBUF_VALID( sb )    ( (sb)->sb_valid == LBER_VALID_SOCKBUF )
index e16a76c6f92c8c3b356df8dd5eb7beeb8e18caae..b4d7c4194b410d1ca78b8661e9485ed99f054f27 100644 (file)
@@ -73,6 +73,7 @@ ber_sockbuf_ctrl( Sockbuf *sb, int opt, void *arg )
        int                     ret = 0;
 
        assert( sb != NULL );
+       assert( SOCKBUF_VALID( sb ) );
 
        switch ( opt ) {
                case LBER_SB_OPT_HAS_IO:
@@ -124,6 +125,18 @@ ber_sockbuf_ctrl( Sockbuf *sb, int opt, void *arg )
                        ret = ( sb->sb_trans_needs_write ? 1 : 0 );
                        break;
 
+               case LBER_SB_OPT_GET_MAX_INCOMING:
+                       if ( arg != NULL ) {
+                               *((ber_len_t *)arg) = sb->sb_max_incoming;
+                       }
+                       ret = 1;
+                       break;
+
+               case LBER_SB_OPT_SET_MAX_INCOMING:
+                       sb->sb_max_incoming = *((ber_len_t *)arg);
+                       ret = 1;
+                       break;
+
                default:
                        ret = sb->sb_iod->sbiod_io->sbi_ctrl( sb->sb_iod,
                                opt, arg );