Diff for /libraries/liblber/decode.c between versions 1.105.2.5 and 1.108

version 1.105.2.5, 2008/09/02 23:54:37 version 1.108, 2007/03/23 14:27:38
Line 1 Line 1
 /* decode.c - ber input decoding routines */  /* decode.c - ber input decoding routines */
 /* $OpenLDAP: pkg/ldap/libraries/liblber/decode.c,v 1.105.2.4 2008/02/11 23:26:41 kurt Exp $ */  /* $OpenLDAP: pkg/ldap/libraries/liblber/decode.c,v 1.107 2007/03/20 14:10:16 hyc Exp $ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.  /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *   *
  * Copyright 1998-2008 The OpenLDAP Foundation.   * Copyright 1998-2007 The OpenLDAP Foundation.
  * All rights reserved.   * All rights reserved.
  *   *
  * Redistribution and use in source and binary forms, with or without   * Redistribution and use in source and binary forms, with or without
Line 49  static ber_len_t ber_getnint LDAP_P(( Line 49  static ber_len_t ber_getnint LDAP_P((
 int  int
 ber_decode_oid( BerValue *in, BerValue *out )  ber_decode_oid( BerValue *in, BerValue *out )
 {  {
         const unsigned char *der;          unsigned char *der = in->bv_val;
         unsigned long val;          unsigned long val, val1;
         unsigned val1;          int i, len;
         ber_len_t i;  
         char *ptr;          char *ptr;
   
         assert( in != NULL );          assert( in != NULL );
         assert( out != NULL );          assert( out != NULL );
   
         /* need 4 chars/inbyte + \0 for input={7f 7f 7f...} */          /* expands by 5/2, and we add dots - call it 3 */
         if ( !out->bv_val || (out->bv_len+3)/4 <= in->bv_len )          if ( !out->bv_val || out->bv_len < in->bv_len * 3 )
                 return -1;                  return -1;
   
         ptr = NULL;          val1 = der[0] / 40;
         der = (unsigned char *) in->bv_val;          val = der[0] - val1 * 40;
   
           len = sprintf( out->bv_val, "%ld.%ld", val1, val );
           ptr = out->bv_val + len;
         val = 0;          val = 0;
         for ( i=0; i < in->bv_len; i++ ) {          for ( i=1; i<in->bv_len; i++ ) {
                   val = val << 7;
                 val |= der[i] & 0x7f;                  val |= der[i] & 0x7f;
                 if ( !( der[i] & 0x80 )) {                  if ( !( der[i] & 0x80 )) {
                         if ( ptr == NULL ) {                          ptr += sprintf( ptr, ".%ld", val );
                                 /* Initial "x.y": val=x*40+y, x<=2, y<40 if x<2 */  
                                 ptr = out->bv_val;  
                                 val1 = (val < 80 ? val/40 : 2);  
                                 val -= val1*40;  
                                 ptr += sprintf( ptr, "%u", val1 );  
                         }  
                         ptr += sprintf( ptr, ".%lu", val );  
                         val = 0;                          val = 0;
                 } else if ( val - 1UL < LBER_OID_COMPONENT_MAX >> 7 ) {  
                         val <<= 7;  
                 } else {  
                         /* val would overflow, or is 0 from invalid initial 0x80 octet */  
                         return -1;  
                 }                  }
         }          }
         if ( ptr == NULL || val != 0 )  
                 return -1;  
   
         out->bv_len = ptr - out->bv_val;          out->bv_len = ptr - out->bv_val;
         return 0;          return 0;
 }  }
Line 419  ber_get_stringbvl( bgbvr *b, ber_len_t * Line 407  ber_get_stringbvl( bgbvr *b, ber_len_t *
         case BvOff:          case BvOff:
                 *b->res.ba = ber_memalloc_x( (n+1) * b->siz, b->ber->ber_memctx );                  *b->res.ba = ber_memalloc_x( (n+1) * b->siz, b->ber->ber_memctx );
                 if ( *b->res.ba == NULL ) return LBER_DEFAULT;                  if ( *b->res.ba == NULL ) return LBER_DEFAULT;
                 ((struct berval *)((char *)(*b->res.ba) + n*b->siz +                  ((struct berval *)((long)(*b->res.ba) + n*b->siz +
                         b->off))->bv_val = NULL;                          b->off))->bv_val = NULL;
                 break;                  break;
         }          }
Line 452  ber_get_stringbvl( bgbvr *b, ber_len_t * Line 440  ber_get_stringbvl( bgbvr *b, ber_len_t *
                         *bvp = bv;                          *bvp = bv;
                         break;                          break;
                 case BvOff:                  case BvOff:
                         *(BerVarray)((char *)(*b->res.ba)+n*b->siz+b->off) = bv;                          *(BerVarray)((long)(*b->res.ba)+n*b->siz+b->off) = bv;
                         break;                          break;
                 }                  }
         }          }
Line 780  ber_scanf ( BerElement *ber, Line 768  ber_scanf ( BerElement *ber,
   
         fmt_reset = fmt;          fmt_reset = fmt;
   
         if ( ber->ber_debug & (LDAP_DEBUG_TRACE|LDAP_DEBUG_BER)) {          ber_log_printf( LDAP_DEBUG_TRACE, ber->ber_debug,
                 ber_log_printf( LDAP_DEBUG_TRACE, ber->ber_debug,                  "ber_scanf fmt (%s) ber:\n", fmt );
                         "ber_scanf fmt (%s) ber:\n", fmt );          ber_log_dump( LDAP_DEBUG_BER, ber->ber_debug, ber, 1 );
                 ber_log_dump( LDAP_DEBUG_BER, ber->ber_debug, ber, 1 );  
         }  
   
         for ( rc = 0; *fmt && rc != LBER_DEFAULT; fmt++ ) {          for ( rc = 0; *fmt && rc != LBER_DEFAULT; fmt++ ) {
                 /* When this is modified, remember to update                  /* When this is modified, remember to update

Removed from v.1.105.2.5  
changed lines
  Added in v.1.108


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