summaryrefslogtreecommitdiff
path: root/src/init/fs/misc.c
diff options
context:
space:
mode:
authordzwdz2022-04-14 08:34:50 +0200
committerdzwdz2022-04-14 08:34:50 +0200
commitced5298a40faf8250759c34c13c8de0f62924d19 (patch)
treef328c1ab46798a2d24ddde98bfb59dbfa62286cb /src/init/fs/misc.c
parentacf27b6071884c7a0939f26f47d3895d134f5088 (diff)
init/fs: fix `fs_dir_inject`
the loop wasn't bounder, so was copying garbage - including multiple null bytes also, the trailing slash was appended even if the injected path didn't have one
Diffstat (limited to 'src/init/fs/misc.c')
-rw-r--r--src/init/fs/misc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/init/fs/misc.c b/src/init/fs/misc.c
index ddb230f..f140910 100644
--- a/src/init/fs/misc.c
+++ b/src/init/fs/misc.c
@@ -149,10 +149,11 @@ void fs_dir_inject(const char *path) {
struct fs_dir_handle h = handles[res.id];
int out_len = 0;
- while (h.inject[out_len] != '/')
+ while (h.inject[out_len] && h.inject[out_len] != '/')
+ out_len++;
+ if (h.inject[out_len] == '/')
out_len++;
memcpy(buf, h.inject, out_len);
- buf[out_len++] = '/';
buf[out_len++] = '\0';
if (h.delegate >= 0) {