chiark / gitweb /
core: fix crashes if locale.conf contains invalid utf-8 string
authorGoffredo Baroncelli <kreijack@libero.it>
Thu, 6 Feb 2014 18:09:59 +0000 (19:09 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 8 Feb 2014 18:07:39 +0000 (13:07 -0500)
commitf27f0e2177ac0a4b96585aed7db3a080e27a2f00
tree037b2dbedc0da6b3c45a5ce27f3dfbb19b372fab
parentecd2f2c5947d9e2f4d6792c2a3a90b8ced6a5b3e
core: fix crashes if locale.conf contains invalid utf-8 string

In the parse_env_file_push() and load_env_file_push() functions, there
are two assert() call to check if the key or value parameters are utf8 valid.

If the strings aren't utf8 valid, assert does abort.

These function are used early by systemd to parse some files. For
example '/etc/locale.conf'. In my case this file contained a not utf8
sequence, which is bad, but systemd crashed during the boot, which
is even worse!

The enclosed patch removes the assert and return -EINVAL if the
sequence is invalid. This is possible because the caller of these
function [1] checks the errors.
So the check of an invalid utf8 sequence is still performed, but
systemd doesn't crash anymore and logs the error.

[1] parse_env_file_internal(), invoked by load_env_file() and
parse_env_file()
src/shared/fileio.c