This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Stefan Sperling gerrit-no-reply at lists.osmocom.orgStefan Sperling has submitted this change and it was merged. ( https://gerrit.osmocom.org/11943 )
Change subject: fix file descriptor leak in osysmon_file_read
......................................................................
fix file descriptor leak in osysmon_file_read
Don't forget to close the file which was opened at the
beginning of this function's scope. Found by Coverity.
Change-Id: Ie1b5734748438c6d785cd96dfa9af6303cd102da
Related: CID#189756
---
M osysmon_file.c
1 file changed, 4 insertions(+), 2 deletions(-)
Approvals:
Jenkins Builder: Verified
Max: Looks good to me, but someone else must approve
Harald Welte: Looks good to me, approved
diff --git a/osysmon_file.c b/osysmon_file.c
index 6f826b4..3a228fa 100644
--- a/osysmon_file.c
+++ b/osysmon_file.c
@@ -77,7 +77,7 @@
static void osysmon_file_read(struct osysmon_file *of, struct value_node *parent)
{
char buf[512];
- char *nl;
+ char *s, *nl;
FILE *f;
f = fopen(of->cfg.path, "r");
@@ -85,7 +85,9 @@
value_node_add(parent, parent, of->cfg.name, "<NOTFOUND>");
return;
}
- if (fgets(buf, sizeof(buf), f) == NULL) {
+ s = fgets(buf, sizeof(buf), f);
+ fclose(f);
+ if (s == NULL) {
value_node_add(parent, parent, of->cfg.name, "<EMPTY>");
return;
}
--
To view, visit https://gerrit.osmocom.org/11943
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-sysmon
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie1b5734748438c6d785cd96dfa9af6303cd102da
Gerrit-Change-Number: 11943
Gerrit-PatchSet: 2
Gerrit-Owner: Stefan Sperling <ssperling at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Stefan Sperling <ssperling at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181130/1dc4a3db/attachment.htm>