Diff for /libraries/liblber/decode.c between versions 1.2 and 1.4.10.2

version 1.2, 1998/08/08 23:35:59 version 1.4.10.2, 1998/09/23 06:13:37
Line 11 Line 11
  * is provided ``as is'' without express or implied warranty.   * is provided ``as is'' without express or implied warranty.
  */   */
   
   #define DISABLE_BRIDGE /* disable LDAP_BRIDGE code */
   #include "portable.h"
   
 #include <stdio.h>  #include <stdio.h>
   
 #ifdef MACOS  #ifdef MACOS
 #include <stdlib.h>  #include <stdlib.h>
 #include <stdarg.h>  #include <stdarg.h>
 #include "macos.h"  #include "macos.h"
 #else /* MACOS */  #else /* MACOS */
 #if defined(NeXT) || defined(VMS)  
   #if defined(NeXT) || defined(VMS) || defined(__FreeBSD__)
 #include <stdlib.h>  #include <stdlib.h>
 #else /* next || vms */  #else /* next || vms || freebsd */
 #ifndef __FreeBSD__  
 #include <malloc.h>  #include <malloc.h>
 #endif  #endif /* next || vms || freebsd */
 #endif /* next || vms */  
 #if defined(BC31) || defined(_WIN32)  #if defined(BC31) || defined(_WIN32)
 #include <stdarg.h>  #include <stdarg.h>
 #else /* BC31 || _WIN32 */  #else /* BC31 || _WIN32 */
Line 42 Line 45
 #endif /* DOS */  #endif /* DOS */
   
 #include <string.h>  #include <string.h>
   
 #include "lber.h"  #include "lber.h"
   
 #ifdef LDAP_DEBUG  #ifdef LDAP_DEBUG
 int     lber_debug;  int     lber_debug;
 #endif  #endif
   
 #ifdef NEEDPROTOS  static int ber_getnint LDAP_P(( BerElement *ber, long *num, int len ));
 static int ber_getnint( BerElement *ber, long *num, int len );  
 #endif /* NEEDPROTOS */  
   
   
 /* return the tag - LBER_DEFAULT returned means trouble */  /* return the tag - LBER_DEFAULT returned means trouble */
 unsigned long  unsigned long
Line 157  ber_getnint( BerElement *ber, long *num, Line 158  ber_getnint( BerElement *ber, long *num,
 {  {
         int     diff, sign, i;          int     diff, sign, i;
         long    netnum;          long    netnum;
           char    *p;
   
         /*          /*
          * The tag and length have already been stripped off.  We should           * The tag and length have already been stripped off.  We should
Line 174  ber_getnint( BerElement *ber, long *num, Line 176  ber_getnint( BerElement *ber, long *num,
         if ( ber_read( ber, ((char *) &netnum) + diff, len ) != len )          if ( ber_read( ber, ((char *) &netnum) + diff, len ) != len )
                 return( -1 );                  return( -1 );
   
         /* sign extend if necessary */          /* sign extend if necessary */
         sign = ((0x80 << ((len - 1) * 8)) & netnum);          p = (char *) &netnum;
         if ( sign && len < sizeof(long) ) {          sign = (0x80 & *(p+diff) );
                 for ( i = sizeof(long) - 1; i > len - 1; i-- ) {          if ( sign && len < sizeof(long) ) {
                         netnum |= (0xffL << (i * 8));                  for ( i = 0; i < diff; i++ ) {
                           *(p+i) = 0xff;
                 }                  }
         }          }
         *num = LBER_NTOHL( netnum );          *num = LBER_NTOHL( netnum );

Removed from v.1.2  
changed lines
  Added in v.1.4.10.2


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