head	1.1;
branch	1.1.1;
access;
symbols
	netbsd-11-0-RC7:1.1.1.1.2.2
	netbsd-11:1.1.1.1.0.2
	libXfont2-2-0-8:1.1.1.1
	xorg:1.1.1;
locks; strict;
comment	@ * @;


1.1
date	2026.07.08.08.08.05;	author mrg;	state Exp;
branches
	1.1.1.1;
next	;
commitid	7VdJyWSkIgj0cPMG;

1.1.1.1
date	2026.07.08.08.08.05;	author mrg;	state Exp;
branches
	1.1.1.1.2.1;
next	;
commitid	7VdJyWSkIgj0cPMG;

1.1.1.1.2.1
date	2026.07.08.08.08.05;	author martin;	state dead;
branches;
next	1.1.1.1.2.2;
commitid	TjCsKikLRsNeSfOG;

1.1.1.1.2.2
date	2026.07.19.11.16.00;	author martin;	state Exp;
branches;
next	;
commitid	TjCsKikLRsNeSfOG;


desc
@@


1.1
log
@Initial revision
@
text
@/*
 * PCF encoding offset out-of-bounds access
 *
 * The font has 1 metric but an encoding entry that references index 100,
 * far past the metrics array.  Without the fix, this creates a wild
 * pointer that is later dereferenced.
 *
 * With the fix in pcfread.c, encoding offsets are validated against
 * nmetrics.
 *
 * Test font: test/data/encoding/evil-encoding.pcf
 * Generated by: test/gen_evil_pcf_encoding.py
 */

/*
 * Copyright (c) 2026, Red Hat, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

#include "pcf-test-common.h"
#include <stdio.h>
#include <stdlib.h>

int
main(int argc, char **argv)
{
    xfont2_fpe_funcs_rec const **fpe_functions;
    int fpe_function_count;
    const char *builddir;
    char fontdir[512];

    builddir = getenv("builddir");
    if (!builddir)
        builddir = ".";

    fpe_functions = pcf_test_init(&fpe_function_count);

    snprintf(fontdir, sizeof(fontdir), "%s/test/data/encoding", builddir);
    return pcf_test_open_font(fpe_functions,
                              "pcf-encoding-oob",
                              fontdir,
                              "-evil-encoding-medium-r-normal--10-100-75-75-c-80-iso10646-1");
}
@


1.1.1.1
log
@initial import of libXfont2-2.0.8
@
text
@@


1.1.1.1.2.1
log
@file test-pcf-encoding.c was added on branch netbsd-11 on 2026-07-19 11:16:00 +0000
@
text
@d1 61
@


1.1.1.1.2.2
log
@Pull up the following, requested by mrg in ticket #378:

	xsrc/external/mit/libXfont2/dist/test/gen_evil_pcf_bitmapscale.py up to 1.1.1.1
	xsrc/external/mit/libXfont2/dist/test/gen_evil_pcf_encoding.py up to 1.1.1.1
	xsrc/external/mit/libXfont2/dist/test/gen_evil_pcf_norepad.py up to 1.1.1.1
	xsrc/external/mit/libXfont2/dist/test/gen_evil_pcf_props.py up to 1.1.1.1
	xsrc/external/mit/libXfont2/dist/test/gen_evil_pcf_repad.py up to 1.1.1.1
	xsrc/external/mit/libXfont2/dist/test/pcf-test-common.c up to 1.1.1.1
	xsrc/external/mit/libXfont2/dist/test/pcf-test-common.h up to 1.1.1.1
	xsrc/external/mit/libXfont2/dist/test/test-pcf-bitmapscale.c up to 1.1.1.1
	xsrc/external/mit/libXfont2/dist/test/test-pcf-encoding.c up to 1.1.1.1
	xsrc/external/mit/libXfont2/dist/test/test-pcf-norepad.c up to 1.1.1.1
	xsrc/external/mit/libXfont2/dist/test/test-pcf-props.c up to 1.1.1.1
	xsrc/external/mit/libXfont2/dist/test/test-pcf-repad.c up to 1.1.1.1
	xsrc/external/mit/libXfont2/dist/test-driver         up to 1.1.1.1
	xsrc/external/mit/libXfont2/dist/ChangeLog           up to 1.1.1.7
	xsrc/external/mit/libXfont2/dist/Makefile.am         up to 1.1.1.4
	xsrc/external/mit/libXfont2/dist/Makefile.in         up to 1.1.1.7
	xsrc/external/mit/libXfont2/dist/aclocal.m4          up to 1.1.1.7
	xsrc/external/mit/libXfont2/dist/compile             up to 1.1.1.4
	xsrc/external/mit/libXfont2/dist/config.guess        up to 1.1.1.5
	xsrc/external/mit/libXfont2/dist/config.h.in         up to 1.1.1.6
	xsrc/external/mit/libXfont2/dist/config.sub          up to 1.1.1.6
	xsrc/external/mit/libXfont2/dist/configure           up to 1.1.1.7
	xsrc/external/mit/libXfont2/dist/configure.ac        up to 1.1.1.7
	xsrc/external/mit/libXfont2/dist/depcomp             up to 1.1.1.4
	xsrc/external/mit/libXfont2/dist/install-sh          up to 1.1.1.5
	xsrc/external/mit/libXfont2/dist/ltmain.sh           up to 1.1.1.6
	xsrc/external/mit/libXfont2/dist/missing             up to 1.1.1.4
	xsrc/external/mit/libXfont2/dist/doc/Makefile.in     up to 1.1.1.7
	xsrc/external/mit/libXfont2/dist/include/X11/fonts/bdfint.h up to 1.1.1.2
	xsrc/external/mit/libXfont2/dist/m4/libtool.m4       up to 1.1.1.2
	xsrc/external/mit/libXfont2/dist/m4/ltoptions.m4     up to 1.1.1.2
	xsrc/external/mit/libXfont2/dist/m4/ltsugar.m4       up to 1.1.1.2
	xsrc/external/mit/libXfont2/dist/m4/ltversion.m4     up to 1.1.1.2
	xsrc/external/mit/libXfont2/dist/m4/lt~obsolete.m4   up to 1.1.1.2
	xsrc/external/mit/libXfont2/dist/src/FreeType/ftenc.c up to 1.1.1.3
	xsrc/external/mit/libXfont2/dist/src/bitmap/bdfread.c up to 1.1.1.4
	xsrc/external/mit/libXfont2/dist/src/bitmap/pcfread.c up to 1.1.1.5
	xsrc/external/mit/libXfont2/dist/src/builtins/render.c up to 1.1.1.2
	xsrc/external/mit/libXfont2/dist/src/fc/fsio.c       up to 1.1.1.3
	xsrc/external/mit/libXfont2/dist/test/utils/font-test-utils.c up to 1.1.1.4

Import latest libXfont2
@
text
@a0 61
/*
 * PCF encoding offset out-of-bounds access
 *
 * The font has 1 metric but an encoding entry that references index 100,
 * far past the metrics array.  Without the fix, this creates a wild
 * pointer that is later dereferenced.
 *
 * With the fix in pcfread.c, encoding offsets are validated against
 * nmetrics.
 *
 * Test font: test/data/encoding/evil-encoding.pcf
 * Generated by: test/gen_evil_pcf_encoding.py
 */

/*
 * Copyright (c) 2026, Red Hat, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

#include "pcf-test-common.h"
#include <stdio.h>
#include <stdlib.h>

int
main(int argc, char **argv)
{
    xfont2_fpe_funcs_rec const **fpe_functions;
    int fpe_function_count;
    const char *builddir;
    char fontdir[512];

    builddir = getenv("builddir");
    if (!builddir)
        builddir = ".";

    fpe_functions = pcf_test_init(&fpe_function_count);

    snprintf(fontdir, sizeof(fontdir), "%s/test/data/encoding", builddir);
    return pcf_test_open_font(fpe_functions,
                              "pcf-encoding-oob",
                              fontdir,
                              "-evil-encoding-medium-r-normal--10-100-75-75-c-80-iso10646-1");
}
@


