mirror of
https://github.com/troglobit/finit.git
synced 2026-10-08 16:34:45 +07:00
Fix GCC 9 string trunction warning
- Increase size of resulting path buffer, unlikely a real problem - Check return value from snprintf() to detect errors and truncation - Add logit() function wrapper to initctl, maps to _e()/_d()/_pe() Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -46,8 +46,9 @@ int pid_file_parse (svc_t *svc, char *arg);
|
||||
*/
|
||||
static inline char *pid_runpath(const char *file, char *path, size_t len)
|
||||
{
|
||||
static int unknown = 1;
|
||||
static char *prefix = "/var/run";
|
||||
static int unknown = 1;
|
||||
int rc;
|
||||
|
||||
if (unknown) {
|
||||
if (fisdir("/run"))
|
||||
@@ -60,7 +61,9 @@ static inline char *pid_runpath(const char *file, char *path, size_t len)
|
||||
else if (!strncmp(file, "/run/", 5))
|
||||
file += 5;
|
||||
|
||||
snprintf(path, len, "%s/%s", prefix, file);
|
||||
rc = snprintf(path, len, "%s/%s", prefix, file);
|
||||
if (rc < 0 || (size_t)rc >= len)
|
||||
_e("File path '%s' truncated, should end with '%s'", path, file);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user