From: Howard Chu Date: Sun, 2 Dec 2007 21:46:50 +0000 (+0000) Subject: Cleanup overflow check X-Git-Tag: OPENLDAP_REL_ENG_2_4_9~20^2~361 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ccfe26fca9f4a8d235af58d8959c6052e4487c21;p=openldap Cleanup overflow check --- diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index df955ade6e..38af3d2ffa 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -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 )) {