On 2017-10-12 13:39, [ext] Andreas J. Reichel wrote: > 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 | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/tools/ebgpart.c b/tools/ebgpart.c > index f80bdfe..ef99ace 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; >
We should be still leaking fd when running into the cpt_out_of_mem branch, no? Jan -- Siemens AG, Corporate Technology, CT RDA ITP SES-DE Corporate Competence Center Embedded Linux -- 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/b082d95b-b605-d55b-cb37-3d0dfd52fd7c%40siemens.com. For more options, visit https://groups.google.com/d/optout.
