• [PATCH] no longer allower upper case or unterscore characters in packag

    From Bernhard R. Link@21:1/5 to All on Sun Jul 7 14:50:01 2024
    Without this patch The C function pkg_name_is_illegal still allows
    upper case characters und underscores in packages names.

    This especially causes dpkg-deb to still be able to create packages
    with upper case characters in them. (underscores are already impossible
    because check_control_file checks the lowercased packagename).

    This change also makes it impossible to install .deb files with
    upper case characters in their control file. As the /var/lib/dpkg/status
    file gets the lowercased names (both for package names and dependencies)
    this could only break a system which has packages installed with
    underscores in their names, which is extremely unlikely as dpkg-deb
    could not build them.

    ---

    Different sets of characters being allowed at different places has
    caused a lot of confusion and some bugs over the years and
    especially the handling of upper case characters has a (low) chance
    of allowing to circumventing some security measures somewhere.
    As the only commercial .deb files with upper case characters are already
    fixed since some years, I think it is preferable to fix it at once
    instead of only fixing dpkg-deb now.

    ---
    lib/dpkg/parsehelp.c | 7 +++----
    1 file changed, 3 insertions(+), 4 deletions(-)

    diff --git a/lib/dpkg/parsehelp.c b/lib/dpkg/parsehelp.c
    index a999b5e78..1a041b133 100644
    --- a/lib/dpkg/parsehelp.c
    +++ b/lib/dpkg/parsehelp.c
    @@ -139,8 +139,7 @@ find_arbfield_info(const struct arbitraryfield *arbs, const char *fieldname)
    const char *
    pkg_name_is_illegal(const char *p)
    {
    - /* TODO: _ is deprecated, remove sometime. */
    - static const char alsoallowed[] = "-+._";
    + static const char allowed[] = "-+.abcdefghijklmnopqrstuvwxyz0123456789";
    st
  • From Guillem Jover@21:1/5 to Bernhard R. Link on Thu Jul 11 04:50:02 2024
    Hi!

    On Sun, 2024-07-07 at 14:34:11 +0200, Bernhard R. Link wrote:
    Without this patch The C function pkg_name_is_illegal still allows
    upper case characters und underscores in packages names.

    This especially causes dpkg-deb to still be able to create packages
    with upper case characters in them. (underscores are already impossible because check_control_file checks the lowercased packagename).

    This change also makes it impossible to install .deb files with
    upper case characters in their control file. As the /var/lib/dpkg/status
    file gets the lowercased names (both for package names and dependencies)
    this could only break a system which has packages installed with
    underscores in their names, which is extremely unlikely as dpkg-deb
    could not build them.

    ---

    Different sets of characters being allowed at different places has
    caused a lot of confusion and some bugs over the years and
    especially the handling of upper case characters has a (low) chance
    of allowing to circumventing some security measures somewhere.
    As the only commercial .deb files with upper case characters are already fixed since some years, I think it is preferable to fix it at once
    instead of only fixing dpkg-deb now.

    Ah, thanks for the reminder! My initial motivation for wanting this,
    apart from refusing bogus packages, was for performance reasons, as the
    db code currently needs to duplicate the package name and lower case it
    before it can add it to the in-core db. But I've also been annoyed
    by this not being more strict, and third party packages having used
    uppercase letters.

    I had:

    https://git.hadrons.org/cgit/debian/dpkg/dpkg.git/commit/?h=pu/optimize-speed&id=28e2d32b2a7621ac0649cbc091b8391b30f36857

    Which I'll try to polish and finish up in the coming days for merging,
    but probably after the current release. Where I can also include soft-disallowing the underscore, but this needs to be done in an
    incremental way, otherwise potentially existing packages in the db
    might render the whole packaging system non-operational. :/

    ---
    lib/dpkg/parsehelp.c | 7 +++----
    1 file changed, 3 insertions(+), 4 deletions(-)

    diff --git a/lib/dpkg/parsehelp.c b/lib/dpkg/parsehelp.c
    index a999b5e78..1a041b133 100644
    --- a/lib/dpkg/parsehelp.c
    +++ b/lib/dpkg/parsehelp.c
    @@ -139,8 +139,7 @@ find_arbfield_info(const struct arbitraryfield *arbs, const char *fieldname)
    const char *
    pkg_name_is_illegal(const char *p)
    {
    - /* TODO: _ is deprecated, remove sometime. */
    - static const char alsoallowed[] = "-+._";
    + static const char allowed[] = "-+.abcdefghijklmnopqrstuvwxyz0123456789";
    static char buf[150];
    int c;

    @@ -148,13 +147,13 @@ pkg_name_is_illegal(const char *p)
    if (!c_isalnum(*p))
    return _("must start with an alphanumeric character");
    while ((c = *p++) != '\0')
    - if (!c_isalnum(c) && !strchr(alsoallowed, c))
    + if (!strchr(allowed, c))

    This does not seem very efficient, though. :) See my above patch,
    although I also have another commit that I'll probably unearth to
    add a character type class for package names, which could be handy
    with this rework.

    https://git.hadrons.org/cgit/debian/dpkg/dpkg.git/commit/?h=pu/c-ctype&id=a233d3704ec788b9b18e0dbe97ca6d2e75048444

    Thanks,
    Guillem

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)