case Decision::DENY:
return false;
case Decision::CHECK:
- std::sprintf(uid_str, "%lu", (unsigned long)uid);
+ std::snprintf(uid_str, sizeof(uid_str) - 1, "%lu", (unsigned long)uid);
return ldp_cynara::Cynara::check(label, privilege, uid_str) == ldp_cynara::CynaraResult::ALLOW;
}
struct passwd pwent;
struct passwd *pwd;
char buf[1024];
- if (getpwnam_r(user, &pwent, buf, sizeof(buf), &pwd) && pwd)
+ if (getpwnam_r(user, &pwent, buf, sizeof(buf), &pwd) || !pwd)
return (uid_t)-1;
return pwd->pw_uid;
struct group grent;
struct group *gg;
char buf[1024];
- if (getgrnam_r(group, &grent, buf, sizeof(buf), &gg) && gg)
+ if (getgrnam_r(group, &grent, buf, sizeof(buf), &gg) || !gg)
return (gid_t)-1;
return gg->gr_gid;
}
bool ItemOwn::match(const Item* item) const {
const ItemOwn* it = dynamic_cast<const ItemOwn*>(item);
+ if (!it)
+ return false;
+
if (__is_prefix) {
int i = 0;
if (!__name)
bool ItemSendReceive::match(const Item* item) const {
const ItemSendReceive* it = dynamic_cast<const ItemSendReceive*>(item);
+ if (!it)
+ return false;
+
if (__type != MessageType::ANY && __type != it->__type)
return false;