summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@kernel.org>2024-04-22 22:40:43 +0200
committerAlejandro Colomar <alx@kernel.org>2024-06-18 22:59:44 +0200
commita9aed2044c6191b93af0199aa77b26ab39cbbad2 (patch)
tree59a76e36a27bd0613579e117b3268aa0d5aec733 /src
parent7b7b303a729508c4a6a02c2dd46e94c5683ad2a2 (diff)
downloadunit-a9aed2044c6191b93af0199aa77b26ab39cbbad2.tar.gz
unit-a9aed2044c6191b93af0199aa77b26ab39cbbad2.tar.bz2
fs: Correctly handle "/" in nxt_fs_mkdir_dirname()
The previous code attempted to mkdir(""), that is an empty string. Since "/" necessarily exists, just goto out_free. Fixes: 57fc9201cb91 ("Socket: Created control socket & pid file directories.") Link: <https://github.com/nginx/unit/issues/742> Tested-by: Andy Postnikov <apostnikov@gmail.com> Tested-by: Andrew Clayton <a.clayton@nginx.com> Reviewed-by: Andrew Clayton <a.clayton@nginx.com> Cc: Liam Crilly <liam@nginx.com> Cc: Konstantin Pavlov <thresh@nginx.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
Diffstat (limited to 'src')
-rw-r--r--src/nxt_fs.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/nxt_fs.c b/src/nxt_fs.c
index 6a93c670..788c3ee2 100644
--- a/src/nxt_fs.c
+++ b/src/nxt_fs.c
@@ -1,5 +1,6 @@
/*
* Copyright (C) NGINX, Inc.
+ * Copyright 2024, Alejandro Colomar <alx@kernel.org>
*/
#include <nxt_main.h>
@@ -58,7 +59,7 @@ nxt_fs_mkdir_dirname(const u_char *path, mode_t mode)
ret = NXT_OK;
ptr = strrchr(dir, '/');
- if (nxt_slow_path(ptr == NULL)) {
+ if (ptr == dir || nxt_slow_path(ptr == NULL)) {
goto out_free;
}