]> git.sur5r.net Git - openldap/commitdiff
Fix 1.426, must sign-extend small numbers, not zero-pad
authorHoward Chu <hyc@openldap.org>
Fri, 30 Nov 2007 18:12:17 +0000 (18:12 +0000)
committerHoward Chu <hyc@openldap.org>
Fri, 30 Nov 2007 18:12:17 +0000 (18:12 +0000)
servers/slapd/schema_init.c

index ee96f4e6868f6c7ed8d82cd2d97c737bd7c73dfd..3d9cbb3b6100abbc45c4b76b5019821633501f73 100644 (file)
@@ -2161,13 +2161,17 @@ integerIndexer(
                        rc = LDAP_INVALID_SYNTAX;
                        goto leave;
                }
-               /* If too small, pad with zeros */
+               /* If too small, sign-extend */
                if ( iv.bv_len < index_intlen ) {
-                       int j, k;
+                       int j, k, pad;
                        keys[i].bv_val[0] = index_intlen;
+                       if (iv.bv_val[0] & 0x80)
+                               pad = 0xff;
+                       else
+                               pad = 0;
                        k = index_intlen - iv.bv_len + 1;
                        for ( j=1; j<k; j++)
-                               keys[i].bv_val[j] = 0;
+                               keys[i].bv_val[j] = pad;
                        for ( j = 0; j<iv.bv_len; j++ )
                                keys[i].bv_val[j+k] = iv.bv_val[j];
                } else {