[systemd-devel] [PATCH v2] localed: validate set-x11-keymap input

Susant Sahani susant at redhat.com
Fri Nov 14 05:10:37 PST 2014


On 11/14/2014 05:12 PM, Jan Synacek wrote:
> +int xkb_keymap_get_components(X11Keymap *keymap) {
> +        _cleanup_strv_free_ char **models = NULL, **options = NULL;
> +        _cleanup_fclose_ FILE *f;
> +        char line[LINE_MAX];
> +        enum KeymapComponent state = NONE;
> +        size_t m = 0, o = 0, allocm = 0, alloco = 0;
> +
> +        Hashmap *x11_layouts;
> +        int r;
> +
> +        x11_layouts = hashmap_new(&string_hash_ops);
> +        if (!x11_layouts)
> +                return log_oom();
> +
> +        f = fopen("/usr/share/X11/xkb/rules/base.lst", "re");
> +        if (!f) {
> +                log_error("Failed to open keyboard mapping list. %m");

  isn't x11_layouts leaking memory here ? should not we free this
> +                return -errno;
> +        }
> +
> +        FOREACH_LINE(line, f, break) {
> +                char *l, *w;
> +                _cleanup_free_ char *layout = NULL;
> +
> +                l = strstrip(line);
> +
> +                if (isempty(l))
> +                        continue;

Susant


More information about the systemd-devel mailing list