From: Andreas Reichel <[email protected]> * Test for fd < 0 instead of fd == 0 * close fd before return to prevent handle leak
Signed-off-by: Andreas Reichel <[email protected]> --- tools/ebgpart.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/ebgpart.c b/tools/ebgpart.c index f80bdfe..ed8a0bb 100644 --- a/tools/ebgpart.c +++ b/tools/ebgpart.c @@ -255,7 +255,7 @@ static bool check_partition_table(PedDevice *dev) VERBOSE(stdout, "Checking %s\n", dev->path); fd = open(dev->path, O_RDONLY); - if (fd == 0) { + if (fd < 0) { VERBOSE(stderr, "Error opening block device.\n"); return false; } @@ -294,6 +294,7 @@ static bool check_partition_table(PedDevice *dev) struct EFIHeader efihdr; if (read(fd, &efihdr, sizeof(efihdr)) != sizeof(efihdr)) { + close(fd); VERBOSE(stderr, "Error reading EFI Header\n."); VERBOSE(stderr, "(%s)", strerror(errno)); return false; @@ -340,6 +341,7 @@ static bool check_partition_table(PedDevice *dev) } continue; cpt_out_of_mem: + close(fd); if (pfst) free(pfst); if (tmp) free(tmp); return false; -- 2.14.2 -- You received this message because you are subscribed to the Google Groups "EFI Boot Guard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/efibootguard-dev/20171012120447.24067-1-andreas.reichel.ext%40siemens.com. For more options, visit https://groups.google.com/d/optout.
