]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9955 liblunicode: fix buffer size in UTF8bvnormalize
authorHoward Chu <hyc@openldap.org>
Thu, 24 Nov 2022 21:32:51 +0000 (21:32 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Mon, 5 Dec 2022 16:30:29 +0000 (16:30 +0000)
output buffer may overrun 1 byte for specially crafted approxMatch search filters.
Not exploitable, no operational or security impact.

libraries/liblunicode/ucstr.c

index e95db43e7df6c0bdae97029cfc979d616877faed..88b41fcd38b89b9b1eb404f9c3312ec5855cef59 100644 (file)
@@ -240,6 +240,17 @@ fail:
                if ( approx ) {
                        for ( j = 0; j < ucsoutlen; j++ ) {
                                if ( ucsout[j] < 0x80 ) {
+                                       if ( outpos >= outsize ) {
+                                               outsize += ( ucsoutlen - j ) + 1;
+                                               outtmp = (char *) ber_memrealloc_x( out, outsize, ctx );
+                                               if ( outtmp == NULL ) {
+                                                       ber_memfree_x( ucsout, ctx );
+                                                       ber_memfree_x( ucs, ctx );
+                                                       ber_memfree_x( out, ctx );
+                                                       goto fail;
+                                               }
+                                               out = outtmp;
+                                       }
                                        out[outpos++] = ucsout[j];
                                }
                        }