Discussion:
[netcf-devel] [PATCH 0/3] A few fixes to placate Coverity
Laine Stump
2018-09-17 14:14:57 UTC
Permalink
Admittedly patch 1 was a legitimate leak....

Laine Stump (3):
Fix memory leak in aug_match_mac()
remove unused variable in aug_match_mac()
Make the empty body of for loops more obvious

src/dutil_linux.c | 4 ++--
src/ncftool.c | 9 ++++++---
2 files changed, 8 insertions(+), 5 deletions(-)

--
2.14.4
_______________________________________________
netcf-devel mailing list -- netcf-***@lists.fedorahosted.org
To unsubscribe send an email to netcf-devel-***@lists.fedorahosted.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedorahosted.org/archives/list/netcf-***@lists.fedorahoste
Laine Stump
2018-09-17 14:14:58 UTC
Permalink
mac_lower has memory allocated to it, but it was only freed in case of
an error.

Signed-off-by: Laine Stump <***@laine.org>
---
src/dutil_linux.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/src/dutil_linux.c b/src/dutil_linux.c
index 742153a..80c08f7 100644
--- a/src/dutil_linux.c
+++ b/src/dutil_linux.c
@@ -423,6 +423,7 @@ int aug_match_mac(struct netcf *ncf, const char *mac, char ***matches) {
(*matches)[i] = n;
}

+ FREE(mac_lower);
return nmatches;

error:
--
2.14.4
_______________________________________________
netcf-devel mailing list -- netcf-***@lists.fedorahosted.org
To unsubscribe send an email to netcf-devel-***@lists.fedorahosted.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedorahosted.org/archive
Laine Stump
2018-09-17 14:15:00 UTC
Permalink
parseline() was skipping over non-option commandline args with 3 for
loops that had empty bodies signified by semicolons at the end of the
for() line (twice) or with a body comprised completely of a nested
for() that had an empty body. Coverity didn't like this. Put braces
around all three loop bodies to make the intent more clear.

Signed-off-by: Laine Stump <***@laine.org>
---
src/ncftool.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/ncftool.c b/src/ncftool.c
index 382c91d..eecb449 100644
--- a/src/ncftool.c
+++ b/src/ncftool.c
@@ -655,9 +655,12 @@ static int parseline(struct command *cmd, char *line) {
}
for (def = cmd->def->opts;
def->name != NULL && !opt_def_is_arg(def);
- def++);
- for (int i=0; i < curarg; i++)
- for (; def->name != NULL && !opt_def_is_arg(def); def++);
+ def++) {
+ }
+ for (int i=0; i < curarg; i++) {
+ for (; def->name != NULL && !opt_def_is_arg(def); def++) {
+ }
+ }
struct command_opt *opt =
make_command_opt(cmd, def);
opt->string = tok;
--
2.14.4
_______________________________________________
netcf-devel mailing list -- netcf-***@lists.fedorahosted.org
To unsubscribe send an email to netcf-devel-***@lists.fedorahosted.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedorahosted.org/archives/lis
Laine Stump
2018-09-17 14:14:59 UTC
Permalink
Apparently this wasn't caught by the compiler because it was
initialized, and that counted as a "use".

Signed-off-by: Laine Stump <***@laine.org>
---
src/dutil_linux.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/dutil_linux.c b/src/dutil_linux.c
index 80c08f7..6442df4 100644
--- a/src/dutil_linux.c
+++ b/src/dutil_linux.c
@@ -399,7 +399,7 @@ void free_matches(int nint, char ***intf) {
/* Returns a list of all interfaces with MAC address MAC */
int aug_match_mac(struct netcf *ncf, const char *mac, char ***matches) {
int nmatches;
- char *path = NULL, *mac_lower = NULL;
+ char *mac_lower = NULL;

mac_lower = strdup(mac);
ERR_NOMEM(mac_lower == NULL, ncf);
@@ -428,7 +428,6 @@ int aug_match_mac(struct netcf *ncf, const char *mac, char ***matches) {

error:
FREE(mac_lower);
- FREE(path);
return -1;
}

--
2.14.4
_______________________________________________
netcf-devel mailing list -- netcf-***@lists.fedorahosted.org
To unsubscribe send an email to netcf-devel-***@lists.fedorahosted.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedorahosted.org/archives/list/ne
Eric Blake
2018-09-17 19:06:29 UTC
Permalink
Post by Laine Stump
Admittedly patch 1 was a legitimate leak....
Fix memory leak in aug_match_mac()
remove unused variable in aug_match_mac()
Make the empty body of for loops more obvious
ACK series
Post by Laine Stump
src/dutil_linux.c | 4 ++--
src/ncftool.c | 9 ++++++---
2 files changed, 8 insertions(+), 5 deletions(-)
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
_______________________________________________
netcf-devel mailing list -- netcf-***@lists.fedorahosted.org
To unsubscribe send an email to netcf-devel-***@lists.fedorahosted.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedorahosted.org/archives/list/

Loading...