]> git.sur5r.net Git - openldap/commitdiff
Cleanup overflow check
authorHoward Chu <hyc@openldap.org>
Sun, 2 Dec 2007 21:46:50 +0000 (21:46 +0000)
committerHoward Chu <hyc@openldap.org>
Sun, 2 Dec 2007 21:46:50 +0000 (21:46 +0000)
servers/slapd/schema_init.c

index df955ade6eb0465cd8b3b41fd7edd51d78eb8d31..38af3d2ffa5309ef7756241a08985a076df496c6 100644 (file)
@@ -2146,12 +2146,12 @@ integerVal2Key(
        /* Chop least significant digits, increase length instead */
        if ( val.bv_len > k ) {
                chop = (val.bv_len-k+2)/INDEX_INTLEN_CHOP; /* 2 fewer digits */
-               val.bv_len -= chop * INDEX_INTLEN_CHOP; /* #digits chopped */
-               chop *= INDEX_INTLEN_CHOPBYTES;         /* #bytes added */
-               if ( chop > 0x7fffffff ) {
+               if ( chop > 0x7fffffff / INDEX_INTLEN_CHOPBYTES ) {
                        memset( key->bv_val, neg ^ 0xff, index_intlen );
                        return 0;
                }
+               val.bv_len -= chop * INDEX_INTLEN_CHOP; /* #digits chopped */
+               chop *= INDEX_INTLEN_CHOPBYTES;         /* #bytes added */
        }
 
        if ( lutil_str2bin( &val, &itmp, ctx )) {