Skip to content

systemd-firstboot: segfault when using --locale-messages=xxx without --locale=yyy #25249

@mrc0mmand

Description

@mrc0mmand

systemd version the issue has been seen with

latest main

Used distribution

Fedora 36, Fedora Rawhide

Linux kernel version used

No response

CPU architectures issue was seen on

No response

Component

No response

Expected behaviour you didn't see

No response

Unexpected behaviour you saw

systemd-firstboot dies with a segmentation fault when you call it with --locale-messages=foo without also specifying --locale=bar:

# mkdir root
# systemd-firstboot --root=root --locale-messages=foo 
Segmentation fault (core dumped)

but:

# systemd-firstboot --root=root --locale-messages=foo --locale=foo
/root/root/etc/locale.conf written.

Most likely caused by missing isempty(arg_locale) check in this condition:

if (!isempty(arg_locale_messages) && !streq(arg_locale_messages, arg_locale))
locales[i++] = strjoina("LC_MESSAGES=", arg_locale_messages);

Steps to reproduce the problem

No response

Additional program output to the terminal or log subsystem illustrating the issue

(gdb) bt full
#0  __strcmp_evex () at ../sysdeps/x86_64/multiarch/strcmp-evex.S:295
No locals.
#1  0x0000557444eb172b in process_locale () at ../src/firstboot/firstboot.c:342
        etc_localeconf = 0x7ffd40217b80 "/root/root/etc/locale.conf"
        locales = {0x0, 0x0, 0x0}
        i = 0
        r = <optimized out>
        __PRETTY_FUNCTION__ = "process_locale"
        __func__ = "process_locale"
#2  0x0000557444eaff93 in run (argv=0x7ffd40217d98, argc=3) at ../src/firstboot/firstboot.c:1401
        loop_device = 0x0
        unlink_dir = 0x0
        r = <optimized out>
        loop_device = <optimized out>
        unlink_dir = <optimized out>
        r = <optimized out>
        __func__ = <optimized out>
        __PRETTY_FUNCTION__ = <optimized out>
        enabled = <optimized out>
        _error = <optimized out>
        _level = <optimized out>
        _e = <optimized out>
        _level = <optimized out>
        _e = <optimized out>
#3  main (argc=3, argv=0x7ffd40217d98) at ../src/firstboot/firstboot.c:1432
        r = <optimized out>
        __PRETTY_FUNCTION__ = "main"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Programming errors, that need preferential fixingfirstboot

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions