if ((tag = get_tag(sb, ber)) == LBER_DEFAULT ) {
unsigned long tag = get_tag(sb, ber); unsigned long newlen;  if (tag == LBER_DEFAULT ) {
ber_get_next( Sockbuf *sb, unsigned long *len, BerElement *ber ){	unsigned long	tag, toread, newlen;	long		rc;#ifdef LDAP_DEBUG	if ( lber_debug )		ber_err_print( "ber_get_next\n" );#endif	/*	 * first time through - malloc the buffer, set up ptrs, and	 * read the tag and the length and as much of the rest as we can	 */	if ( ber->ber_rwptr == NULL ) {	  /* read the tag */	  if ((tag = get_tag(sb, ber)) == LBER_DEFAULT ) {	    return( LBER_DEFAULT );	  }	  if((sb->sb_options & LBER_SOCKBUF_OPT_VALID_TAG) &&	     (tag != sb->sb_valid_tag)) {	    return( LBER_DEFAULT);          }	  ber->ber_tag_contents[0] = (char)tag; /* we only handle 1 byte tags */	  	  /* read the length */	  if ((newlen = read_len_in_ber(sb, ber)) == LBER_DEFAULT ) {	    return( LBER_DEFAULT );	  }	  /*	   * Finally, malloc a buffer for the contents and read it in.	   * It's this buffer that's passed to all the other ber decoding	   * routines.	   */	  #if defined( DOS ) && !( defined( _WIN32 ) || defined(XP_OS2) )	  if ( newlen > 65535 ) {	/* DOS can't allocate > 64K */	    return( LBER_DEFAULT );	  }#endif /* DOS && !_WIN32 */	  	  if ( ( sb->sb_options & LBER_SOCKBUF_OPT_MAX_INCOMING_SIZE )	       && newlen > sb->sb_max_incoming ) {	    return( LBER_DEFAULT );	  }	  	  /* check to see if we already have enough memory allocated */	  if ( (ber->ber_end - ber->ber_buf) < (size_t)newlen) {	  	    if ( (ber->ber_buf = (char *)NSLBERI_CALLOC( 1,(size_t)newlen ))		 == NULL ) {	      return( LBER_DEFAULT );	    }	    ber->ber_flags &= ~LBER_FLAG_NO_FREE_BUFFER;	  }	  	  ber->ber_len = newlen;	  ber->ber_ptr = ber->ber_buf;	  ber->ber_end = ber->ber_buf + newlen;	  ber->ber_rwptr = ber->ber_buf;	}	/* OK, we've malloc-ed the buffer; now read the rest of the expected length */	toread = (unsigned long)ber->ber_end - (unsigned long)ber->ber_rwptr;	do {	  if ( (rc = BerRead( sb, ber->ber_rwptr, (long)toread )) <= 0 ) {	    return( LBER_DEFAULT );	  }	  	  toread -= rc;	  ber->ber_rwptr += rc;	} while ( toread > 0 );	#ifdef LDAP_DEBUG	if ( lber_debug ) {	  char msg[80];	  sprintf( msg, "ber_get_next: tag 0x%lx len %ld contents:\n",		   tag, ber->ber_len );	  ber_err_print( msg );	  if ( lber_debug > 1 )	    ber_dump( ber, 1 );	}#endif			ber->ber_rwptr = NULL;	*len = newlen;	ber->ber_struct[BER_STRUCT_VAL].ldapiov_len = newlen;	return(tag);}