[LTP] [PATCH v4] tst_tmpdir: Fix buffer overflow in tst_tmpdir.c
Andrea Cervesato
andrea.cervesato@suse.com
Thu Feb 26 10:36:40 CET 2026
Hi!
On Thu Feb 26, 2026 at 9:59 AM CET, Cyril Hrubis wrote:
> Hi!
> > diff --git a/lib/tst_tmpdir.c b/lib/tst_tmpdir.c
> > index 9b024a74e..0c06a306c 100644
> > --- a/lib/tst_tmpdir.c
> > +++ b/lib/tst_tmpdir.c
> > @@ -186,8 +186,10 @@ static int purge_dirat(int dir_fd, const char *path, char **errptr)
> > continue;
> >
> > /* Recursively remove the current entry */
> > - if (rmobjat(subdir_fd, dir_ent->d_name, errptr) != 0)
> > + if (rmobjat(subdir_fd, dir_ent->d_name, errptr) != 0) {
> > + close(subdir_fd); <<<<<<<<<< first close
> > ret_val = -1;
> > + }
> > }
> >
> > closedir(dir); <<<<<<<<<<<<< second close
>
> Ah, right, we hand the fd to the fdopendir() and it's closed in the
> closedir() call. I've missed that since the closedir() is not shown in
> the diff since that part of the code wasn't modified and haven't shown
> up in the diff.
>
> The patch looks good to me then.
Feel free to ack and merge :-)
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
More information about the ltp
mailing list