X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Fliblunicode%2Fucstr.c;h=6d947737164344690ce63af5c131966f9186b72b;hb=1e436aba370d47ab738c5ea320a440b1042698f8;hp=d854b2aead48fc17fdba9632b88fe7f4f4111cd0;hpb=6aff66cf6741acc4f2dba2452430b1d5eaf17910;p=openldap diff --git a/libraries/liblunicode/ucstr.c b/libraries/liblunicode/ucstr.c index d854b2aead..6d94773716 100644 --- a/libraries/liblunicode/ucstr.c +++ b/libraries/liblunicode/ucstr.c @@ -1,11 +1,21 @@ -/* - * Copyright 2000-2003 The OpenLDAP Foundation - * COPYING RESTRICTIONS APPLY. See COPYRIGHT File in top level directory - * of this package for details. +/* $OpenLDAP$ */ +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2005 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . */ #include "portable.h" +#include #include #include #include @@ -100,7 +110,7 @@ struct berval * UTF8bvnormalize( { int i, j, len, clen, outpos, ucsoutlen, outsize, last; char *out, *outtmp, *s; - unsigned long *ucs, *p, *ucsout; + ac_uint4 *ucs, *p, *ucsout; static unsigned char mask[] = { 0, 0x7f, 0x1f, 0x0f, 0x07, 0x03, 0x01 }; @@ -252,8 +262,8 @@ struct berval * UTF8bvnormalize( last = i; /* Allocate more space in out if necessary */ - if (len - i > outsize - outpos) { - outsize = outsize + ((len - i) - (outsize - outpos)); + if (len - i >= outsize - outpos) { + outsize += 1 + ((len - i) - (outsize - outpos)); outtmp = (char *) realloc(out, outsize); if (outtmp == NULL) { free(out); @@ -293,7 +303,7 @@ int UTF8bvnormcmp( { int i, l1, l2, len, ulen, res = 0; char *s1, *s2, *done; - unsigned long *ucs, *ucsout1, *ucsout2; + ac_uint4 *ucs, *ucsout1, *ucsout2; unsigned casefold = flags & LDAP_UTF8_CASEFOLD; unsigned norm1 = flags & LDAP_UTF8_ARG1NFC; @@ -373,7 +383,7 @@ int UTF8bvnormcmp( /* * XXYYZ: we convert to ucs4 even though -llunicode - * expects ucs2 in an unsigned long + * expects ucs2 in an ac_uint4 */ /* convert and normalize 1st string */