uint16_t svcSize;
rbuf.extract((char *)&svcSize, 1, 2);
- chklen = svcSize + 3; // packet type + (2 byte) length + service name
- if (svcSize <= 0 || chklen > 1024) {
+ if (svcSize <= 0 || svcSize > (1024 - 3)) {
// Queue error response / mark connection bad
char badreqRep[] = { DINIT_RP_BADREQ };
if (! queue_packet(badreqRep, 1)) return false;
iob.set_watches(OUT_EVENTS);
return true;
}
+ chklen = svcSize + 3; // packet type + (2 byte) length + service name
if (rbuf.get_length() < chklen) {
// packet not complete yet; read more
// we find a gap in the handle values.
handle_t candidate = 0;
for (auto p : key_service_map) {
- if (p.first == candidate) candidate++;
+ if (p.first == candidate) ++candidate;
else break;
}
}
else if (shutdown_type == shutdown_type_t::REBOOT) {
// Non-system-process. If we got SIGINT, let's die due to it:
- sigset_t sigwait_set;
- sigemptyset(&sigwait_set);
- sigaddset(&sigwait_set, SIGINT);
+ sigset_t sigwait_set_int;
+ sigemptyset(&sigwait_set_int);
+ sigaddset(&sigwait_set_int, SIGINT);
raise(SIGINT);
- sigprocmask(SIG_UNBLOCK, &sigwait_set, NULL);
+ sigprocmask(SIG_UNBLOCK, &sigwait_set_int, NULL);
}
return 0;
public:
- service_record(service_set *set, string name)
+ service_record(service_set *set, const string &name)
: service_name(name), service_state(service_state_t::STOPPED),
desired_state(service_state_t::STOPPED), auto_restart(false), smooth_recovery(false),
pinned_stopped(false), pinned_started(false), waiting_for_deps(false),
socket_perms = 0;
}
- service_record(service_set *set, string name, service_type_t record_type_p,
+ service_record(service_set *set, const string &name, service_type_t record_type_p,
const std::list<prelim_dep> &deplist_p)
: service_record(set, name)
{
}
// Set logfile, should be done before service is started
- void set_log_file(string logfile)
+ void set_log_file(const string &logfile)
{
this->logfile = logfile;
}