Fix issue with pid://../run/foo..pid parser

Unfortunately we cannot use realpath(3) here since the the PID files
usually do not yet exist at this point.

Add and modify my ugly de_dotdot() from Merecat httpd.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2023-02-05 18:16:27 +01:00
1 parent a67b2ba9a7
commit 82c6e4680f
5 files changed
+52 -6

No files matched your search

+5 -1
View File
@@ -149,6 +149,8 @@ int pid_file_create(svc_t *svc)
int pid_file_set(svc_t *svc, char *file, int not)
{
char buf[sizeof(svc->pidfile)];
if (!file) {
file = pid_file(svc);
if (!file)
@@ -165,7 +167,9 @@ int pid_file_set(svc_t *svc, char *file, int not)
not = 1;
}
pid_runpath(file, &svc->pidfile[not], sizeof(svc->pidfile) - not);
de_dotdot(file);
pid_runpath(file, buf, sizeof(buf));
strlcpy(&svc->pidfile[not], buf, sizeof(svc->pidfile) - not);
if (not)
svc->pidfile[0] = '!';