summaryrefslogtreecommitdiffstats
path: root/src/basic/fileio.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-04-08 16:40:22 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-04-09 08:50:22 +0200
commit07d8c0eb1e037b7be16e9065a4bce784d7abf372 (patch)
treedea051e220f741232470b1e6829ab07cc45e00fb /src/basic/fileio.c
parentfileio: read_full_file_full() also warns when file is world readable and secu... (diff)
downloadsystemd-07d8c0eb1e037b7be16e9065a4bce784d7abf372.tar.xz
systemd-07d8c0eb1e037b7be16e9065a4bce784d7abf372.zip
fileio: add READ_FULL_FILE_UNBASE64 flag for read_full_file_full()
Diffstat (limited to 'src/basic/fileio.c')
-rw-r--r--src/basic/fileio.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/basic/fileio.c b/src/basic/fileio.c
index 78928979e9..9ab2f501c7 100644
--- a/src/basic/fileio.c
+++ b/src/basic/fileio.c
@@ -17,6 +17,7 @@
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
+#include "hexdecoct.h"
#include "log.h"
#include "macro.h"
#include "missing.h"
@@ -278,6 +279,7 @@ int read_full_stream_full(
assert(f);
assert(ret_contents);
+ assert(!(flags & READ_FULL_FILE_UNBASE64) || ret_size);
n_next = LINE_MAX; /* Start size */
@@ -354,6 +356,12 @@ int read_full_stream_full(
n_next = MIN(n * 2, READ_FULL_BYTES_MAX);
}
+ if (flags & READ_FULL_FILE_UNBASE64) {
+ buf[l++] = 0;
+ r = unbase64mem_full(buf, l, flags & READ_FULL_FILE_SECURE, (void **) ret_contents, ret_size);
+ goto finalize;
+ }
+
if (!ret_size) {
/* Safety check: if the caller doesn't want to know the size of what we just read it will rely on the
* trailing NUL byte. But if there's an embedded NUL byte, then we should refuse operation as otherwise