parser: fix issues appointed by coverity

Fix issues introduced in coverity's snapshots 75887, 70858 and 75429.
- CID 353483: Uninitialized pointer field (UNINIT_CTOR)
- CID 349572: Unsigned compared against 0 (NO_EFFECT)

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
This commit is contained in:
Georgia Garcia 2024-03-18 10:18:03 -03:00
parent 2fc80487f7
commit f9527d2113
3 changed files with 3 additions and 5 deletions

View file

@ -29,8 +29,6 @@
class all_rule: public prefix_rule_t { class all_rule: public prefix_rule_t {
void move_conditionals(struct cond_entry *conds); void move_conditionals(struct cond_entry *conds);
public: public:
char *label;
all_rule(void): prefix_rule_t(RULE_TYPE_ALL) { } all_rule(void): prefix_rule_t(RULE_TYPE_ALL) { }
virtual bool valid_prefix(const prefixes &p, const char *&error) { virtual bool valid_prefix(const prefixes &p, const char *&error) {

View file

@ -344,8 +344,8 @@ bool parse_port_number(const char *port_entry, uint16_t *port) {
char *eptr; char *eptr;
unsigned long port_tmp = strtoul(port_entry, &eptr, 10); unsigned long port_tmp = strtoul(port_entry, &eptr, 10);
if (port_tmp >= 0 && port_entry != eptr && if (port_entry != eptr && *eptr == '\0' &&
*eptr == '\0' && port_tmp <= UINT16_MAX) { port_tmp <= UINT16_MAX) {
*port = port_tmp; *port = port_tmp;
return true; return true;
} }

View file

@ -157,7 +157,7 @@ public:
/* empty constructor used only for the profile to access /* empty constructor used only for the profile to access
* static elements to maintain compatibility with * static elements to maintain compatibility with
* AA_CLASS_NET */ * AA_CLASS_NET */
network_rule(): dedup_perms_rule_t(AA_CLASS_NETV8) { } network_rule(): dedup_perms_rule_t(AA_CLASS_NETV8), label(NULL) { }
network_rule(perms_t perms_p, struct cond_entry *conds, network_rule(perms_t perms_p, struct cond_entry *conds,
struct cond_entry *peer_conds); struct cond_entry *peer_conds);
network_rule(perms_t perms_p, const char *family, const char *type, network_rule(perms_t perms_p, const char *family, const char *type,