Merge branch 'dev'

Fixes to issues found by Coverity Scan

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2025-07-06 15:53:12 +02:00
4 changed files with 19 additions and 15 deletions
+2 -3
View File
@@ -78,10 +78,9 @@ int sd_notify(int unset_environment, const char *state)
unsetenv("NOTIFY_SOCKET");
written = write(sd, state, len);
if (written != (ssize_t) len) {
close(sd);
close(sd);
if (written != (ssize_t) len)
return written < 0 ? -errno : -EPROTO;
}
return 1;
}
+2
View File
@@ -38,6 +38,7 @@
#ifdef HAVE_SYS_SYSMACROS_H
#include <sys/sysmacros.h>
#endif
#include <sys/prctl.h>
#ifdef _LIBITE_LITE
# include <libite/lite.h>
#else
@@ -626,6 +627,7 @@ int main(int argc, char *argv[])
/*
* Clear command line arguments for ps display, issue #442
*/
prctl(PR_SET_NAME, "init", 0, 0, 0);
for (int i = 1; i < argc; i++)
memset(argv[i], 0, strlen(argv[i]));
+10 -4
View File
@@ -124,7 +124,9 @@ static int parse_level(char **buf, int default_level)
static int do_log(int level, char *msg)
{
syslog(parse_level(&msg, level), "%s", msg);
level = parse_level(&msg, level);
syslog(level, "%s", msg);
return 0;
}
@@ -164,7 +166,7 @@ static int parse_prio(char *arg, int *fac, int *lvl)
}
if (found == -1)
return 1;
goto notfound;
*fac = found;
prio = ptr;
@@ -179,11 +181,15 @@ static int parse_prio(char *arg, int *fac, int *lvl)
}
}
if (found == -1)
if (found == -1) {
notfound:
if (duparg)
free(duparg);
return 1;
}
*lvl = found;
if (duparg != arg)
if (duparg)
free(duparg);
return 0;
+5 -8
View File
@@ -698,8 +698,7 @@ static int service_start(svc_t *svc)
close(fd);
result = -1;
goto fail;
}
if (pid > 1) {
} else if (pid > 0) {
struct sockaddr_un sun;
size_t len;
@@ -722,19 +721,19 @@ static int service_start(svc_t *svc)
}
/* fallthrough */
case SVC_NOTIFY_S6:
close(fd); /* client-end of pipefd for s6 notify */
if (svc->notify == SVC_NOTIFY_S6)
close(fd); /* client-end of pipefd for s6 notify */
result = uev_io_init(ctx, &svc->notify_watcher, service_notify_cb, svc, sd, UEV_READ);
if (result < 0) {
err(1, "%s: failed setting up notify callback", svc_ident(svc, NULL, 0));
if (svc->notify == SVC_NOTIFY_S6)
close(fd);
close(sd);
break;
}
default:
break;
}
} else if (pid == 0) {
} else { /* pid == 0 */
char str[strlen(NOTIFY_PATH) + 32];
char *args[MAX_NUM_SVC_ARGS + 1];
int status;
@@ -885,8 +884,6 @@ static int service_start(svc_t *svc)
syslog(LOG_ERR, "failed starting %s, exit code %d: %s", svc_ident(svc, NULL, 0),
status, strerror(errno));
_exit(status);
} else if (debug) {
dbg("Starting PID %d: %s", svc->pid, cmdline);
}
if (!svc_is_sysv(svc))