[LTP] [PATCH v4] tst_tmpdir: Fix buffer overflow in tst_tmpdir.c

Cyril Hrubis chrubis@suse.cz
Thu Feb 26 13:26:06 CET 2026


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 :-)

Done, thanks Andrea and Wei.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list