]> git.sur5r.net Git - openldap/commitdiff
LDAPworldP22: problem with msgids greater than 32767 on 64bit architectures LDAPworld
authorKurt Zeilenga <kurt@openldap.org>
Sun, 9 Aug 1998 03:40:29 +0000 (03:40 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sun, 9 Aug 1998 03:40:29 +0000 (03:40 +0000)
libraries/liblber/decode.c

index a722c9eb7a319a12ad027c85310c1d9c6264ccb4..368dedf4bb7fbf0bd1deb5db718c91877dc527ea 100644 (file)
@@ -155,6 +155,7 @@ ber_getnint( BerElement *ber, long *num, int len )
 {
        int     diff, sign, i;
        long    netnum;
+       char    *p;
 
        /*
         * The tag and length have already been stripped off.  We should
@@ -172,11 +173,12 @@ ber_getnint( BerElement *ber, long *num, int len )
        if ( ber_read( ber, ((char *) &netnum) + diff, len ) != len )
                return( -1 );
 
-       /* sign extend if necessary */
-       sign = ((0x80 << ((len - 1) * 8)) & netnum);
-       if ( sign && len < sizeof(long) ) {
-               for ( i = sizeof(long) - 1; i > len - 1; i-- ) {
-                       netnum |= (0xffL << (i * 8));
+        /* sign extend if necessary */
+        p = (char *) &netnum;
+        sign = (0x80 & *(p+diff) );
+        if ( sign && len < sizeof(long) ) {
+                for ( i = 0; i < diff; i++ ) {
+                        *(p+i) = 0xff;
                }
        }
        *num = LBER_NTOHL( netnum );