Diff for /libraries/liblber/encode.c between versions 1.55 and 1.55.2.4

version 1.55, 2003/05/02 11:29:28 version 1.55.2.4, 2004/07/25 21:56:40
Line 1 Line 1
 /* Encode.c - ber output encoding routines */  /* encode.c - ber output encoding routines */
 /* $OpenLDAP: pkg/ldap/libraries/liblber/encode.c,v 1.54 2003/04/10 04:14:16 hyc Exp $ */  /* $OpenLDAP: pkg/ldap/libraries/liblber/encode.c,v 1.55.2.3 2004/01/01 18:16:29 kurt Exp $ */
 /*  /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.   *
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file   * Copyright 1998-2004 The OpenLDAP Foundation.
    * All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted only as authorized by the OpenLDAP
    * Public License.
    *
    * A copy of this license is available in the file LICENSE in the
    * top-level directory of the distribution or, alternatively, at
    * <http://www.OpenLDAP.org/license.html>.
  */   */
 /* Portions  /* Portions Copyright (c) 1990 Regents of the University of Michigan.
  * Copyright (c) 1990 Regents of the University of Michigan.  
  * All rights reserved.   * All rights reserved.
  *   *
  * Redistribution and use in source and binary forms are permitted   * Redistribution and use in source and binary forms are permitted
Line 15 Line 23
  * software without specific prior written permission. This software   * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.   * is provided ``as is'' without express or implied warranty.
  */   */
   /* ACKNOWLEDGEMENTS:
    * This work was originally developed by the University of Michigan
    * (as part of U-MICH LDAP).
    */
   
 #include "portable.h"  #include "portable.h"
   
Line 97  ber_calc_lenlen( ber_len_t len ) Line 109  ber_calc_lenlen( ber_len_t len )
          * with bit 8 0.           * with bit 8 0.
          */           */
   
         if ( len <= (ber_len_t) 0x7FU )          if ( len <= (ber_len_t) 0x7FU ) return 1;
                 return 1;  
   
         /*          /*
          * long len otherwise - one byte with bit 8 set, giving the           * long len otherwise - one byte with bit 8 set, giving the
          * length of the length, followed by the length itself.           * length of the length, followed by the length itself.
          */           */
   
         if ( len <= (ber_len_t) 0xffU )          if ( len <= (ber_len_t) 0xffU ) return 2;
                 return 2;          if ( len <= (ber_len_t) 0xffffU ) return 3;
         if ( len <= (ber_len_t) 0xffffU )          if ( len <= (ber_len_t) 0xffffffU ) return 4;
                 return 3;  
         if ( len <= (ber_len_t) 0xffffffU )  
                 return 4;  
   
         return 5;          return 5;
 }  }
Line 149  ber_put_len( BerElement *ber, ber_len_t Line 157  ber_put_len( BerElement *ber, ber_len_t
                 if ( len & mask ) break;                  if ( len & mask ) break;
         }          }
         lenlen = (unsigned char) ++i;          lenlen = (unsigned char) ++i;
         if ( lenlen > 4 )          if ( lenlen > 4 ) return -1;
                 return -1;  
   
         lenlen |= 0x80UL;          lenlen |= 0x80UL;
   
         /* write the length of the length */          /* write the length of the length */
         if ( ber_write( ber, &lenlen, 1, nosos ) != 1 )          if ( ber_write( ber, &lenlen, 1, nosos ) != 1 ) return -1;
                 return -1;  
   
         for( j=0; j<i; j++) {          for( j=0; j<i; j++) {
                 netlen[(sizeof(ber_len_t)-1) - j] = (unsigned char)(len & 0xffU);                  netlen[(sizeof(ber_len_t)-1) - j] = (unsigned char)(len & 0xffU);
Line 220  ber_put_int_or_enum( Line 226  ber_put_int_or_enum(
                 return -1;                  return -1;
         }          }
   
         if ( (lenlen = ber_put_len( ber, len, 0 )) == -1 )          if ( (lenlen = ber_put_len( ber, len, 0 )) == -1 ) {
                 return -1;                  return -1;
           }
         i++;          i++;
   
         for( j=0; j<i; j++ ) {          for( j=0; j<i; j++ ) {
Line 291  ber_put_ostring( Line 298  ber_put_ostring(
                 return -1;                  return -1;
   
         if ( (lenlen = ber_put_len( ber, len, 0 )) == -1 ||          if ( (lenlen = ber_put_len( ber, len, 0 )) == -1 ||
                 (ber_len_t) ber_write( ber, str, len, 0 ) != len ) {                  (ber_len_t) ber_write( ber, str, len, 0 ) != len )
           {
                 rc = -1;                  rc = -1;
         } else {          } else {
                 /* return length of tag + length + contents */                  /* return length of tag + length + contents */
Line 421  ber_put_boolean( Line 429  ber_put_boolean(
   
         c = boolval ? (unsigned char) ~0U : (unsigned char) 0U;          c = boolval ? (unsigned char) ~0U : (unsigned char) 0U;
   
         if ( ber_write( ber, (char *) &c, 1, 0 )          if ( ber_write( ber, (char *) &c, 1, 0 ) != 1 ) {
                 != 1 )  
         {  
                 return -1;                  return -1;
         }          }
   
Line 541  ber_put_seqorset( BerElement *ber ) Line 547  ber_put_seqorset( BerElement *ber )
   
         if ( (next = (*sos)->sos_next) == NULL ) {          if ( (next = (*sos)->sos_next) == NULL ) {
                 /* write the tag */                  /* write the tag */
                 if ( (taglen = ber_put_tag( ber, (*sos)->sos_tag, 1 )) == -1 )                  if ( (taglen = ber_put_tag( ber, (*sos)->sos_tag, 1 )) == -1 ) {
                         return( -1 );                          return( -1 );
                   }
   
                 if ( ber->ber_options & LBER_USE_DER ) {                  if ( ber->ber_options & LBER_USE_DER ) {
                         /* Write the length in the minimum # of octets */                          /* Write the length in the minimum # of octets */
Line 823  ber_printf( BerElement *ber, LDAP_CONST Line 830  ber_printf( BerElement *ber, LDAP_CONST
                         break;                          break;
                 }                  }
   
                 if ( ber->ber_usertag == 0 )                  if ( ber->ber_usertag == 0 ) {
                         ber->ber_tag = LBER_DEFAULT;                          ber->ber_tag = LBER_DEFAULT;
                 else                  } else {
                         ber->ber_usertag = 0;                          ber->ber_usertag = 0;
                   }
         }          }
   
         va_end( ap );          va_end( ap );

Removed from v.1.55  
changed lines
  Added in v.1.55.2.4


______________
© Copyright 1998-2020, OpenLDAP Foundation, info@OpenLDAP.org