memfd: skip utf-8 escaping if we use a name that was passed in

If a name was passed in as function argument, trust it, and don't do utf-8
encoding for them. Callers are obliged to check the names themselves, and
escape them in case they use anything they got from the outside world.
This commit is contained in:
Daniel Mack 2014-08-19 22:08:54 +02:00
parent 3cd761e4df
commit ea47ff6697

View file

@ -54,13 +54,7 @@ int memfd_new(const char *name) {
if (isempty(pr))
name = "sd";
else {
_cleanup_free_ char *e = NULL;
e = utf8_escape_invalid(pr);
if (!e)
return -ENOMEM;
g = strappend("sd-", e);
g = strappend("sd-", pr);
if (!g)
return -ENOMEM;