1 1.1 mrg /* 2 1.1 mrg * ZDI-CAN-30560: computeProps property buffer heap overflow 3 1.1 mrg * 4 1.1 mrg * The font has 40 duplicate MIN_SPACE properties. When the bitmap 5 1.1 mrg * scaler processes this font, computeProps writes 2 slots per scaledX 6 1.1 mrg * match into the fixed 70-slot property buffer, overflowing after 25 7 1.1 mrg * matches (50 slots + 20 XLFD slots = 70, then overflow). 8 1.1 mrg * 9 1.1 mrg * With the fix in bitscale.c, computeProps checks remaining buffer 10 1.1 mrg * capacity and silently skips properties that would overflow. 11 1.1 mrg * 12 1.1 mrg * The font is stored at pixel=10; loading at pixel=20 triggers the 13 1.1 mrg * scaling path through ComputeScaledProperties -> computeProps. 14 1.1 mrg * 15 1.1 mrg * Test font: test/data/props/evil-props.pcf 16 1.1 mrg * Generated by: test/gen_evil_pcf_props.py 17 1.1 mrg */ 18 1.1 mrg 19 1.1 mrg /* 20 1.1 mrg * Copyright (c) 2026, Red Hat, Inc. 21 1.1 mrg * 22 1.1 mrg * Permission is hereby granted, free of charge, to any person obtaining a 23 1.1 mrg * copy of this software and associated documentation files (the "Software"), 24 1.1 mrg * to deal in the Software without restriction, including without limitation 25 1.1 mrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 26 1.1 mrg * and/or sell copies of the Software, and to permit persons to whom the 27 1.1 mrg * Software is furnished to do so, subject to the following conditions: 28 1.1 mrg * 29 1.1 mrg * The above copyright notice and this permission notice (including the next 30 1.1 mrg * paragraph) shall be included in all copies or substantial portions of the 31 1.1 mrg * Software. 32 1.1 mrg * 33 1.1 mrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 34 1.1 mrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 35 1.1 mrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 36 1.1 mrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 37 1.1 mrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 38 1.1 mrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 39 1.1 mrg * DEALINGS IN THE SOFTWARE. 40 1.1 mrg */ 41 1.1 mrg 42 1.1 mrg #include "pcf-test-common.h" 43 1.1 mrg #include <stdio.h> 44 1.1 mrg #include <stdlib.h> 45 1.1 mrg 46 1.1 mrg int 47 1.1 mrg main(int argc, char **argv) 48 1.1 mrg { 49 1.1 mrg xfont2_fpe_funcs_rec const **fpe_functions; 50 1.1 mrg int fpe_function_count; 51 1.1 mrg const char *builddir; 52 1.1 mrg char fontdir[512]; 53 1.1 mrg 54 1.1 mrg builddir = getenv("builddir"); 55 1.1 mrg if (!builddir) 56 1.1 mrg builddir = "."; 57 1.1 mrg 58 1.1 mrg fpe_functions = pcf_test_init(&fpe_function_count); 59 1.1 mrg 60 1.1 mrg snprintf(fontdir, sizeof(fontdir), "%s/test/data/props", builddir); 61 1.1 mrg return pcf_test_open_font(fpe_functions, 62 1.1 mrg "ZDI-CAN-30560-props", 63 1.1 mrg fontdir, 64 1.1 mrg "-evil-props-medium-r-normal--20-200-75-75-c-80-iso10646-1"); 65 1.1 mrg } 66