{
int diff, sign, i;
long netnum;
+ char *p;
/*
* The tag and length have already been stripped off. We should
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 );