mirror of
https://github.com/troglobit/finit.git
synced 2026-10-25 12:04:36 +00:00
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:
1 parent
a67b2ba9a7
commit
82c6e4680f
5 files changed
+52
-6
No files matched your search
@@ -51,6 +51,7 @@ static inline char *pid_runpath(const char *file, char *path, size_t len)
|
||||
{
|
||||
static char *prefix = "/var/run";
|
||||
static int unknown = 1;
|
||||
char *ptr;
|
||||
int rc;
|
||||
|
||||
if (unknown) {
|
||||
@@ -59,10 +60,9 @@ static inline char *pid_runpath(const char *file, char *path, size_t len)
|
||||
unknown = 0;
|
||||
}
|
||||
|
||||
if (!strncmp(file, "/var/run/", 9))
|
||||
file += 9;
|
||||
else if (!strncmp(file, "/run/", 5))
|
||||
file += 5;
|
||||
ptr = strstr(file, "/run/");
|
||||
if (ptr)
|
||||
file = ptr + 5;
|
||||
|
||||
rc = paste(path, len, prefix, file);
|
||||
if (rc < 0 || (size_t)rc >= len)
|
||||
|
||||
Reference in new issue
Block a user