As memfds are now created by proper kernel API, and not by our functions, we
can't rely on names being escaped/unescaped according to our current logic.
Thus, the only safe way is to remove the escaping and when reading names,
just escape names that are not properly encoded in UTF-8.
Also, remove assert(name) lines from the memfd creation functions, as we
explictly allow name to be NULL.
#include "bus-label.h"
#include "missing.h"
#include "memfd.h"
#include "bus-label.h"
#include "missing.h"
#include "memfd.h"
int memfd_new(const char *name) {
_cleanup_free_ char *g = NULL;
int fd;
int memfd_new(const char *name) {
_cleanup_free_ char *g = NULL;
int fd;
- /* The kernel side is pretty picky about the character
- * set here, let's do the usual bus escaping to deal
- * with that. */
-
- g = bus_label_escape(name);
+ g = utf8_escape_invalid(name);
if (!g)
return -ENOMEM;
name = g;
if (!g)
return -ENOMEM;
name = g;
} else {
char pr[17] = {};
} else {
char pr[17] = {};
else {
_cleanup_free_ char *e = NULL;
else {
_cleanup_free_ char *e = NULL;
- e = bus_label_escape(pr);
+ e = utf8_escape_invalid(pr);
_cleanup_close_ int fd = -1;
int r;
_cleanup_close_ int fd = -1;
int r;
assert(sz > 0);
assert(p);
assert(sz > 0);
assert(p);
- e = bus_label_unescape(n);
+ e = utf8_escape_invalid(n);