deadsimple BSD Security Advisories and Announcements

FreeBSD Errata Notice FreeBSD-EN-23:14.regcomp

Hash: SHA512

FreeBSD-EN-23:14.regcomp                                        Errata Notice
                                                          The FreeBSD Project

Topic:		Incorrect regular expression escape handling

Category:       core
Module:         libc
Announced:      2023-11-08
Affects:        All supported versions of FreeBSD.
Corrected:      2023-09-30 01:40:59 UTC (stable/14, 14.0-STABLE)
                2023-10-01 04:46:02 UTC (releng/14.0, 14.0-BETA5)
                2023-09-30 01:41:23 UTC (stable/13, 13.2-STABLE)
                2023-11-08 00:59:51 UTC (releng/13.2, 13.2-RELEASE-p5)
                2023-09-30 01:41:57 UTC (stable/12, 12.4-STABLE)
                2023-11-08 01:11:09 UTC (releng/12.4, 12.4-RELEASE-p7)

For general information regarding FreeBSD Errata Notices and Security
Advisories, including descriptions of the fields above, security
branches, and the following sections, please visit

I.   Background

The libc regex(3) implementation is responsible for compiling and applying
regular expressions as used in, e.g., grep(1) and sed(1).

II.  Problem Description

In some instances, the regcomp() implementation would inadvertently sign-extend
a character in the regular expression.  Additionally, alphabetic wide-characters
were not properly being considered as such.

III. Impact

Regular expressions supplied to grep(1) or sed(1) that contained an alphabetic
wide-character would incorrectly error out as if a bogus trailing backslash had
been supplied.

IV.  Workaround

No workaround is available.

V.   Solution

Upgrade your system to a supported FreeBSD stable or release / security
branch (releng) dated after the correction date.

Rebooting after the update is not strictly necessary, but it is recommended
in case the error affects some daemon in use.

Perform one of the following:

1) To update your system via a binary patch:

Systems running a RELEASE version of FreeBSD on the amd64, i386, or
(on FreeBSD 13 and later) arm64 platforms can be updated via the
freebsd-update(8) utility:

# freebsd-update fetch
# freebsd-update install

2) To update your system via a source code patch:

The following patches have been verified to apply to the applicable
FreeBSD release branches.

a) Download the relevant patch from the location below, and verify the
detached PGP signature using your PGP utility.

# fetch
# fetch
# gpg --verify regcomp.patch.asc

b) Apply the patch.  Execute the following commands as root:

# cd /usr/src
# patch < /path/to/patch

c) Recompile the operating system using buildworld and installworld as
described in <URL:>.

Restart all daemons that use the library, or reboot the system.

VI.  Correction details

This issue is corrected by the corresponding Git commit hash or Subversion
revision number in the following stable and release branches:

Branch/path                             Hash                     Revision
- -------------------------------------------------------------------------
stable/14/                              56b09feb23d9    stable/14-n265274
releng/14.0/                            408daf2caa92  releng/14.0-n265163
stable/13/                              ac695744e2cf    stable/13-n256440
releng/13.2/                            67264bfe4992  releng/13.2-n254642
stable/12/                                                        r373222
releng/12.4/                                                      r373267
- -------------------------------------------------------------------------

For FreeBSD 13 and later:

Run the following command to see which files were modified by a
particular commit:

# git show --stat <commit hash>

Or visit the following URL, replacing NNNNNN with the hash:


To determine the commit count in a working tree (for comparison against
nNNNNNN in the table above), run:

# git rev-list --count --first-parent HEAD

For FreeBSD 12 and earlier:

Run the following command to see which files were modified by a particular
revision, replacing NNNNNN with the revision number:

# svn diff -cNNNNNN --summarize svn://

Or visit the following URL, replacing NNNNNN with the revision number:


VII. References


The latest revision of this advisory is available at