fix ressource leakage.
Signed-off-by: maximilian attems <max at stro.at>
---
usr/utils/losetup.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/usr/utils/losetup.c b/usr/utils/losetup.c
index 1104fd3..1a47fa9 100644
--- a/usr/utils/losetup.c
+++ b/usr/utils/losetup.c
@@ -339,6 +339,7 @@ int del_loop (const char *device)
}
if (ioctl (fd, LOOP_CLR_FD, 0) < 0) {
perror ("ioctl: LOOP_CLR_FD");
+ close (fd);
return 1;
}
close (fd);
--
1.7.2.3
maximilian attems
2010-Nov-10 15:07 UTC
[klibc] [PATCH 2/2] utils: dd close fds on error pathes
fix several ressource leakages.
Signed-off-by: maximilian attems <max at stro.at>
---
usr/utils/dd.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/usr/utils/dd.c b/usr/utils/dd.c
index 562e2cf..706b8c3 100644
--- a/usr/utils/dd.c
+++ b/usr/utils/dd.c
@@ -486,6 +486,7 @@ int main(int argc, char *argv[])
wr_fd = open(OPT_OF->str, flags, 0666);
if (wr_fd == -1) {
perror("open output file");
+ close(rd_fd);
return 1;
}
}
@@ -493,14 +494,20 @@ int main(int argc, char *argv[])
/*
* Skip obs-sized blocks of output file.
*/
- if (OPT_SEEK->str && skip_blocks(wr_fd, out_buf, seek, obs))
+ if (OPT_SEEK->str && skip_blocks(wr_fd, out_buf, seek, obs)) {
+ close(rd_fd);
+ close(wr_fd);
return 1;
+ }
/*
* Skip ibs-sized blocks of input file.
*/
- if (OPT_SKIP->str && skip_blocks(rd_fd, in_buf, skip, ibs))
+ if (OPT_SKIP->str && skip_blocks(rd_fd, in_buf, skip, ibs)) {
+ close(rd_fd);
+ close(wr_fd);
return 1;
+ }
memset(&stats, 0, sizeof(stats));
--
1.7.2.3