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: 57fc9201cb
("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>
This commit is contained in:
parent
7b7b303a72
commit
a9aed2044c
1 changed files with 2 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue