Security Advisories (23)
CVE-2015-8608 (2017-02-07)

The VDir::MapPathA and VDir::MapPathW functions in Perl 5.22 allow remote attackers to cause a denial of service (out-of-bounds read) and possibly execute arbitrary code via a crafted (1) drive letter or (2) pInName argument.

CVE-2025-40909 (2025-05-30)

Perl threads have a working directory race condition where file operations may target unintended paths. If a directory handle is open at thread creation, the process-wide current working directory is temporarily changed in order to clone that handle for the new thread, which is visible from any third (or more) thread already running. This may lead to unintended operations such as loading code or accessing files from unexpected locations, which a local attacker may be able to exploit. The bug was introduced in commit 11a11ecf4bea72b17d250cfb43c897be1341861e and released in Perl version 5.13.6

CVE-2016-1238 (2016-08-02)

(1) cpan/Archive-Tar/bin/ptar, (2) cpan/Archive-Tar/bin/ptardiff, (3) cpan/Archive-Tar/bin/ptargrep, (4) cpan/CPAN/scripts/cpan, (5) cpan/Digest-SHA/shasum, (6) cpan/Encode/bin/enc2xs, (7) cpan/Encode/bin/encguess, (8) cpan/Encode/bin/piconv, (9) cpan/Encode/bin/ucmlint, (10) cpan/Encode/bin/unidump, (11) cpan/ExtUtils-MakeMaker/bin/instmodsh, (12) cpan/IO-Compress/bin/zipdetails, (13) cpan/JSON-PP/bin/json_pp, (14) cpan/Test-Harness/bin/prove, (15) dist/ExtUtils-ParseXS/lib/ExtUtils/xsubpp, (16) dist/Module-CoreList/corelist, (17) ext/Pod-Html/bin/pod2html, (18) utils/c2ph.PL, (19) utils/h2ph.PL, (20) utils/h2xs.PL, (21) utils/libnetcfg.PL, (22) utils/perlbug.PL, (23) utils/perldoc.PL, (24) utils/perlivp.PL, and (25) utils/splain.PL in Perl 5.x before 5.22.3-RC2 and 5.24 before 5.24.1-RC2 do not properly remove . (period) characters from the end of the includes directory array, which might allow local users to gain privileges via a Trojan horse module under the current working directory.

CVE-2018-6797 (2018-04-17)

An issue was discovered in Perl 5.18 through 5.26. A crafted regular expression can cause a heap-based buffer overflow, with control over the bytes written.

CVE-2018-6798 (2018-04-17)

An issue was discovered in Perl 5.22 through 5.26. Matching a crafted locale dependent regular expression can cause a heap-based buffer over-read and potentially information disclosure.

CVE-2026-57432 (2026-07-13)

Perl versions through 5.43.10 have an integer overflow in S_measure_struct leading to an out-of-bounds heap read in pack and unpack. S_measure_struct adds each item's size times its repeat count to a running total with no overflow check, so a large repeat count in a pack or unpack template wraps the signed SSize_t total negative. The @, X, and x position codes then guard their moves with a signed length comparison that passes when the length is negative, advancing the buffer pointer out of bounds. A template derived from untrusted input can read heap memory past the buffer and return it to the caller.

CVE-2023-47100

In Perl before 5.38.2, S_parse_uniprop_string in regcomp.c can write to unallocated space because a property name associated with a \p{...} regular expression construct is mishandled. The earliest affected version is 5.30.0.

CVE-2026-13221 (2026-07-13)

Perl versions through 5.43.9 produce silently incorrect regular expression matches when an alternation of more than 65535 fixed string branches is compiled into a trie in Perl_study_chunk. When such branches are combined into a trie, the delta between the first branch and the shared tail is stored in a 16-bit field. A branch count above 65535 overflows the field, and the trie's match decision table is truncated with no warning or error. A pattern of this shape produces false positive matches (matching strings it should not) and false negative matches (failing to match strings it should). When such a pattern gates an access or filtering decision, the result is wrong.

CVE-2026-4176 (2026-03-29)

Perl versions from 5.9.4 before 5.40.4-RC1, from 5.41.0 before 5.42.2-RC1, from 5.43.0 before 5.43.9 contain a vulnerable version of Compress::Raw::Zlib. Compress::Raw::Zlib is included in the Perl package as a dual-life core module, and is vulnerable to CVE-2026-3381 due to a vendored version of zlib which has several vulnerabilities, including CVE-2026-27171. The bundled Compress::Raw::Zlib was updated to version 2.221 in Perl blead commit c75ae9cc164205e1b6d6dbd57bd2c65c8593fe94.

CVE-2026-8376 (2026-05-25)

Perl versions through 5.43.10 have a heap buffer overflow when compiling regular expressions with a repeated fixed string on 32-bit builds. Perl_study_chunk in regcomp_study.c checked the size of the joined substring buffer in characters rather than bytes. For a quantified fixed substring with a large minimum count, the byte length mincount * l could overflow SSize_t, producing an undersized SvGROW allocation; the subsequent copy writes past the end of the buffer. A caller that compiles an attacker-controlled regular expression on a 32-bit perl build triggers a heap buffer overflow at compile time.

CVE-2016-6185 (2016-08-02)

The XSLoader::load method in XSLoader in Perl does not properly locate .so files when called in a string eval, which might allow local users to execute arbitrary code via a Trojan horse library under the current working directory.

CVE-2020-12723 (2020-06-05)

regcomp.c in Perl before 5.30.3 allows a buffer overflow via a crafted regular expression because of recursive S_study_chunk calls.

CVE-2020-10878 (2020-06-05)

Perl before 5.30.3 has an integer overflow related to mishandling of a "PL_regkind[OP(n)] == NOTHING" situation. A crafted regular expression could lead to malformed bytecode with a possibility of instruction injection.

CVE-2020-10543 (2020-06-05)

Perl before 5.30.3 on 32-bit platforms allows a heap-based buffer overflow because nested regular expression quantifiers have an integer overflow.

CVE-2018-6913 (2018-04-17)

Heap-based buffer overflow in the pack function in Perl before 5.26.2 allows context-dependent attackers to execute arbitrary code via a large item count.

CVE-2018-18314 (2018-12-07)

Perl before 5.26.3 has a buffer overflow via a crafted regular expression that triggers invalid write operations.

CVE-2018-18313 (2018-12-07)

Perl before 5.26.3 has a buffer over-read via a crafted regular expression that triggers disclosure of sensitive information from process memory.

CVE-2018-18312 (2018-12-05)

Perl before 5.26.3 and 5.28.0 before 5.28.1 has a buffer overflow via a crafted regular expression that triggers invalid write operations.

CVE-2018-18311 (2018-12-07)

Perl before 5.26.3 and 5.28.x before 5.28.1 has a buffer overflow via a crafted regular expression that triggers invalid write operations.

CVE-2017-12883 (2017-09-19)

Buffer overflow in the S_grok_bslash_N function in regcomp.c in Perl 5 before 5.24.3-RC1 and 5.26.x before 5.26.1-RC1 allows remote attackers to disclose sensitive information or cause a denial of service (application crash) via a crafted regular expression with an invalid '\\N{U+...}' escape.

CVE-2017-12837 (2017-09-19)

Heap-based buffer overflow in the S_regatom function in regcomp.c in Perl 5 before 5.24.3-RC1 and 5.26.x before 5.26.1-RC1 allows remote attackers to cause a denial of service (out-of-bounds write) via a regular expression with a '\\N{}' escape and the case-insensitive modifier.

CVE-2015-8853 (2016-05-25)

The (1) S_reghop3, (2) S_reghop4, and (3) S_reghopmaybe3 functions in regexec.c in Perl before 5.24.0 allow context-dependent attackers to cause a denial of service (infinite loop) via crafted utf-8 data, as demonstrated by "a\x80."

CVE-2023-47039 (2023-10-30)

Perl for Windows relies on the system path environment variable to find the shell (cmd.exe). When running an executable which uses Windows Perl interpreter, Perl attempts to find and execute cmd.exe within the operating system. However, due to path search order issues, Perl initially looks for cmd.exe in the current working directory. An attacker with limited privileges can exploit this behavior by placing cmd.exe in locations with weak permissions, such as C:\ProgramData. By doing so, when an administrator attempts to use this executable from these compromised locations, arbitrary code can be executed.

NAME

Locale::Codes::API - a description of the callable function in each module

DESCRIPTION

Although there are several modules in the Locale-Codes distribution, all of them (as of version 3.10) use exactly the same API. As a matter of fact, each of the main callable modules are just wrappers around a central module which does all the real work.

ROUTINES

In order to maintain the documentation for the modules consistently, the functions are all documented here, rather than in the documentation for the separate modules.

The name of the function depends on the module. For example, every module contains a function code2XXX where XXX refers to the type of data. The values of XXX are described in the following table:

XXX       MODULE

country   Locale::Codes::Country
language  Locale::Codes::Language
currency  Locale::Codes::Currency
script    Locale::Codes::Script
langext   Locale::Codes::LangExt
langvar   Locale::Codes::LangVar
langfam   Locale::Codes::LangFam

So, the Locale::Country module contains the function code2country, the Locale::Language module contains the function code2language, etc.

In all of the functions below, CODE refers to a code for one element in the code set. For example, in the two-letter country codes from ISO 3166-1, the code 'fi' is used to refer to the country Finland. CODE is always case insensitive when passed in as an argument, so 'fi', 'FI', and 'Fi' would all be equivalent arguments. When CODE is returned from an argument, it will always be in the case as used in the standard.

CODESET refers to a constant specified in the documentation for each module to label the various code sets. For example, in the Locale::Language module, CODESET could be LOCALE_CODE_ALPHA_2 or LOCALE_CODE_ALPHA_3 (among others). Most functions have a default one, so they do not need to be specified. So the following calls are valid:

code2country("fi");
code2country("fi",LOCALE_CODE_ALPHA_2);
code2country("fin",LOCALE_CODE_ALPHA_3);

Since LOCALE_CODE_ALPHA_2 is the default code set, the first two are identical.

code2XXX ( CODE [,CODESET] [,'retired'] )

These functions take a code and returns a string which contains the name of the element identified. If the code is not a valid code in the CODESET specified then undef will be returned.

The name of the element is the name as specified in the standard, and as a result, different variations of an element name may be returned for different values of CODESET.

For example, the alpha-2 country code set defines the two-letter code "bo" to be "Bolivia, Plurinational State of", whereas the alpha-3 code set defines the code 'bol' to be the country "Bolivia (Plurinational State of)". So:

code2country('bo',LOCALE_CODE_ALPHA_2);
   => 'Bolivia, Plurinational State of'

code2country('bol',LOCALE_CODE_ALPHA_3);
   => 'Bolivia (Plurinational State of)'

By default, only active codes will be used, but if the string 'retired' is passed in as an argument, both active and retired codes will be examined.

XXX2code ( NAME [,CODESET] [,'retired'] )

These functions takes the name of an element (or any of it's aliases) and returns the code that corresponds to it, if it exists. If NAME could not be identified as the name of one of the elements, then undef will be returned.

The name is not case sensitive. Also, any known variation of a name may be passed in.

For example, even though the country name returned using LOCALE_CODE_ALPHA_2 and LOCALE_CODE_ALPHA_3 country codes for Bolivia is different, either country name may be passed in since for each code set (in addition to the alias 'Bolivia'). So:

country2code('Bolivia, Plurinational State of',
             LOCALE_CODE_ALPHA_2);
   => bo

country2code('Bolivia (Plurinational State of)',
             LOCALE_CODE_ALPHA_2);
   => bo

country2code('Bolivia',LOCALE_CODE_ALPHA_2);
   => bo

By default, only active names will be used, but if the string 'retired' is passed in as an argument, both active and retired names will be examined.

XXX_code2code ( CODE ,CODESET ,CODESET2 )

These functions takes a code from one code set, and returns the corresponding code from another code set. CODE must exists in the code set specified by CODESET and must have a corresponding code in the code set specified by CODESET2 or undef will be returned.

Both CODESET and CODESET2 must be explicitly entered.

country_code2code('fin', LOCALE_CODE_ALPHA_3,
                  LOCALE_CODE_ALPHA_2);
   => 'fi'

Note that this function does NOT support retired codes.

all_XXX_codes ( [CODESET] [,'retired'] )

These returns a list of all code in the code set. The codes will be sorted.

By default, only active codes will be returned, but if the string 'retired' is passed in as an argument, both active and retired codes will be returned.

all_XXX_names ( [CODESET] [,'retired'] )

These return a list of all elements names for which there is a corresponding code in the specified code set.

The names returned are exactly as they are specified in the standard, and are sorted.

Since not all elements are listed in all code sets, the list of elements may differ depending on the code set specified.

By default, only active names will be returned, but if the string 'retired' is passed in as an argument, both active and retired names will be returned.

SEMI-PRIVATE ROUTINES

Additional semi-private routines which may be used to modify the internal data are also available. Given their status, they aren't exported, and so need to be called by prefixing the function name with the package name.

These routines do not currently work with retired codes.

MODULE::rename_XXX ( CODE ,NEW_NAME [,CODESET] )

These routines are used to change the official name of an element. At that point, the name returned by the code2XXX routine would be NEW_NAME instead of the name specified in the standard.

The original name will remain as an alias.

For example, the official country name for code 'gb' is 'United Kingdom'. If you want to change that, you might call:

Locale::Codes::Country::rename_country('gb', 'Great Britain');

This means that calling code2country('gb') will now return 'Great Britain' instead of 'United Kingdom'.

If any error occurs, a warning is issued and 0 is returned. An error occurs if CODE doesn't exist in the specified code set, or if NEW_NAME is already in use but for a different element.

If the routine succeeds, 1 is returned.

MODULE::add_XXX ( CODE ,NAME [,CODESET] )

These routines are used to add a new code and name to the data.

Both CODE and NAME must be unused in the data set or an error occurs (though NAME may be used in a different data set).

For example, to create the fictitious country named "Duchy of Grand Fenwick" with codes "gf" and "fen", use the following:

Locale::Codes::Country::add_country("fe","Duchy of Grand Fenwick",
                             LOCALE_CODE_ALPHA_2);

Locale::Codes::Country::add_country("fen","Duchy of Grand Fenwick",
                             LOCALE_CODE_ALPHA_3);

The return value is 1 on success, 0 on an error.

MODULE::delete_XXX ( CODE [,CODESET] )

These routines are used to delete a code from the data.

CODE must refer to an existing code in the code set.

The return value is 1 on success, 0 on an error.

MODULE::add_XXX_alias ( NAME ,NEW_NAME )

These routines are used to add a new alias to the data. They do not alter the return value of the code2XXX function.

NAME must be an existing element name, and NEW_NAME must be unused or an error occurs.

The return value is 1 on success, 0 on an error.

MODULE::delete_XXX_alias ( NAME )

These routines are used to delete an alias from the data. Once removed, the element may not be referred to by NAME.

NAME must be one of a list of at least two names that may be used to specify an element. If the element may only be referred to by a single name, you'll need to use the add_XXX_alias function to add a new alias first, or the remove_XXX function to remove the element entirely.

If the alias is used as the name in any code set, one of the other names will be used instead. Predicting exactly which one will be used requires you to know the order in which the standards were read, which is not reliable, so you may want to use the rename_XXX function to force one of the alternate names to be used.

The return value is 1 on success, 0 on an error.

MODULE::rename_XXX_code ( CODE ,NEW_CODE [,CODESET] )

These routines are used to change the official code for an element. At that point, the code returned by the XXX2code routine would be NEW_CODE instead of the code specified in the standard.

NEW_CODE may either be a code that is not in use, or it may be an alias for CODE (in which case, CODE becomes and alias and NEW_CODE becomes the "real" code).

The original code is kept as an alias, so that the code2XXX routines will work with either the code from the standard or the new code.

However, the all_XXX_codes routine will only return the codes which are considered "real" (which means that the list of codes will now contain NEW_CODE, but will not contain CODE).

MODULE::add_XXX_code_alias ( CODE ,NEW_CODE [,CODESET] )

These routines add an alias for the code. At that point, NEW_CODE and CODE will both work in the code2XXX routines. However, the XXX2code routines will still return the original code.

MODULE::delete_XXX_code_alias ( CODE [,CODESET] )

These routines delete an alias for the code.

These will only work if CODE is actually an alias. If it is the "real" code, it will not be deleted. You will need to use the rename_XXX_code function to switch the real code with one of the aliases, and then delete the alias.

KNOWN BUGS AND LIMITATIONS

Relationship between code sets

Because each code set uses a slightly different list of elements, and they are not necessarily one-to-one, there may be some confusion about the relationship between codes from different code sets.

For example, ISO 3166 assigns one code to the country "United States Minor Outlying Islands", but the IANA codes give different codes to different islands (Baker Island, Howland Island, etc.).

This may cause some confusion... I've done the best that I could do to minimize it.

Non-ASCII characters not supported

Currently all names must be all ASCII. I plan on relaxing that limitation in the future.

SEE ALSO

Locale::Codes

Locale::Codes::Country

Locale::Codes::Language

Locale::Codes::Currency

Locale::Codes::Script

Locale::Codes::LangExt

Locale::Codes::LangVar

Locale::Codes::LangFam

AUTHOR

See Locale::Codes for full author history.

Currently maintained by Sullivan Beck (sbeck@cpan.org).

COPYRIGHT

Copyright (c) 1997-2001 Canon Research Centre Europe (CRE).
Copyright (c) 2001-2010 Neil Bowers
Copyright (c) 2010-2015 Sullivan Beck

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.