summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-08-19 22:35:04 +0200
committerLennart Poettering <lennart@poettering.net>2014-08-19 22:35:04 +0200
commit5755381f53ab52d22d20a711c219f7de3ba62397 (patch)
treebeba77ba4d0ea55233277da6604a7383180a5d66 /src/shared
parenta1a4a25e7f6b515d0c8c25257714299853f261aa (diff)
memfd: escape the comm field we get from PR_GET_NAME, but assume everything else is proper UTF8
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/memfd.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/shared/memfd.c b/src/shared/memfd.c
index c21642f49a..1feca0c979 100644
--- a/src/shared/memfd.c
+++ b/src/shared/memfd.c
@@ -32,17 +32,10 @@
#include "utf8.h"
int memfd_new(const char *name) {
-
_cleanup_free_ char *g = NULL;
int fd;
- if (name) {
- g = utf8_escape_invalid(name);
- if (!g)
- return -ENOMEM;
-
- name = g;
- } else {
+ if (!name) {
char pr[17] = {};
/* If no name is specified we generate one. We include
@@ -54,7 +47,13 @@ int memfd_new(const char *name) {
if (isempty(pr))
name = "sd";
else {
- g = strappend("sd-", pr);
+ _cleanup_free_ char *e = NULL;
+
+ e = utf8_escape_invalid(pr);
+ if (!e)
+ return -ENOMEM;
+
+ g = strappend("sd-", e);
if (!g)
return -ENOMEM;
@@ -130,7 +129,7 @@ int memfd_get_size(int fd, uint64_t *sz) {
return -errno;
*sz = stat.st_size;
- return r;
+ return 0;
}
int memfd_set_size(int fd, uint64_t sz) {
@@ -142,7 +141,7 @@ int memfd_set_size(int fd, uint64_t sz) {
if (r < 0)
return -errno;
- return r;
+ return 0;
}
int memfd_new_and_map(const char *name, size_t sz, void **p) {