diff options
author | leo-arch <leonardoabramovich2@gmail.com> | 2022-07-26 19:50:11 -0300 |
---|---|---|
committer | leo-arch <leonardoabramovich2@gmail.com> | 2022-07-26 19:50:11 -0300 |
commit | 0ef5556390da642a1c8ba22a63e628c309a74724 (patch) | |
tree | f4d63654a800c66556885e1318c67df4f8aed9c6 | |
parent | 8bcadfce105f96b291457f62cda3db5e269c3408 (diff) |
Fix double slash in tmp dir on OpenBSD
-rw-r--r-- | src/config.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/config.c b/src/config.c index 5b617125..208ad48d 100644 --- a/src/config.c +++ b/src/config.c @@ -526,8 +526,12 @@ create_tmp_files(void) * in here, but only the file's owner can remove or modify them */ size_t user_len = user.name ? strlen(user.name) : 7; /* 7: length of "unknown" */ tmp_dir = (char *)xnmalloc(P_tmpdir_len + pnl_len + user_len + 3, sizeof(char)); - sprintf(tmp_dir, "%s/%s", P_tmpdir, PNL); - /* P_tmpdir is defined in stdio.h and it's value is usually /tmp */ + if (P_tmpdir_len > 0 && P_tmpdir[P_tmpdir_len - 1] == '/') + sprintf(tmp_dir, "%s%s", P_tmpdir, PNL); /* On OpenBSD we get "/tmp/" */ + else + sprintf(tmp_dir, "%s/%s", P_tmpdir, PNL); + /* P_tmpdir is defined in stdio.h and it's value is usually /tmp + * If not defined, it will be defined as "/tmp" */ int tmp_root_ok = 1; struct stat attr; |