* [libnl-nft PATCH] Fix file descriptor leak on error
@ 2012-12-25 14:21 Thomas Jarosch
2012-12-27 6:23 ` Patrick McHardy
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Jarosch @ 2012-12-25 14:21 UTC (permalink / raw)
To: Patrick McHardy; +Cc: netfilter-devel
Detected by cppcheck
Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
---
lib/utils.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/lib/utils.c b/lib/utils.c
index 4007bee..50ca6d9 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -60,24 +60,32 @@ int __nl_read_num_str_file(const char *path, int (*cb)(long, const char *))
continue;
num = strtol(buf, &end, 0);
- if (end == buf)
+ if (end == buf) {
+ fclose(fd);
return -NLE_INVAL;
+ }
- if (num == LONG_MIN || num == LONG_MAX)
+ if (num == LONG_MIN || num == LONG_MAX) {
+ fclose(fd);
return -NLE_RANGE;
+ }
while (*end == ' ' || *end == '\t')
end++;
goodlen = strcspn(end, "#\r\n\t ");
- if (goodlen == 0)
+ if (goodlen == 0) {
+ fclose(fd);
return -NLE_INVAL;
+ }
end[goodlen] = '\0';
err = cb(num, end);
- if (err < 0)
+ if (err < 0) {
+ fclose(fd);
return err;
+ }
}
fclose(fd);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-12-27 9:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-25 14:21 [libnl-nft PATCH] Fix file descriptor leak on error Thomas Jarosch
2012-12-27 6:23 ` Patrick McHardy
2012-12-27 9:49 ` Thomas Jarosch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).