[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nano-devel] check stat's result to avoid referencing unitialized da
From: |
Kamil Dudka |
Subject: |
Re: [Nano-devel] check stat's result to avoid referencing unitialized data |
Date: |
Tue, 09 Feb 2016 15:48:01 +0100 |
User-agent: |
KMail/4.14.10 (Linux/4.3.5-300.fc23.x86_64; KDE/4.14.16; x86_64; ; ) |
On Tuesday 09 February 2016 15:31:27 Benno Schulenberg wrote:
> On Mon, Feb 8, 2016, at 09:35, Kamil Dudka wrote:
> > On Saturday 06 February 2016 11:35:29 Benno Schulenberg wrote:
> > > So I think this part should be:
> > >
> > > - /* Update current_stat to reference the file as it is now. */
> > > - if (openfile->current_stat == NULL)
> > > - openfile->current_stat =
> > > - (struct stat *)nmalloc(sizeof(struct stat));
> > > - if (!openfile->mark_set)
> > > - stat(realname, openfile->current_stat);
> > > + if (!openfile->mark_set) {
> > > + if (openfile->current_stat == NULL)
> > > + openfile->current_stat =
> > > + (struct stat *)nmalloc(sizeof(struct stat));
> > > +
> > > + /* Update the stat info to reflect the file as it is now. */
> > > + if (stat(realname, openfile->current_stat) != 0) {
> > > + free(openfile->current_stat);
> > > + openfile->current_stat = NULL;
> > > + }
> > > + }
> >
> > Looks good to me.
>
> I've reworked the patch a bit to reduce the number of lines.
> See attached.
I am fine with your version of the patch. Thank you for reworking it!
Kamil
> If you can think of a better name than 'stat_with_alloc',
> do let me know.
>
> Benno
- [Nano-devel] [PATCH 2/2] use futimens() if available, instead of utime(), (continued)
- [Nano-devel] [PATCH 2/2] use futimens() if available, instead of utime(), Kamil Dudka, 2016/02/03
- Re: [Nano-devel] [PATCH 2/2] use futimens() if available, instead of utime(), Mike Frysinger, 2016/02/03
- Re: [Nano-devel] [PATCH 2/2] use futimens() if available, instead of utime(), Kamil Dudka, 2016/02/03
- [Nano-devel] begin using gnulib?, Benno Schulenberg, 2016/02/04
- Re: [Nano-devel] begin using gnulib?, Mike Frysinger, 2016/02/04
- Re: [Nano-devel] begin using gnulib?, Chris Allegretta, 2016/02/05
- Re: [Nano-devel] begin using gnulib?, Kamil Dudka, 2016/02/05
Re: [Nano-devel] [PATCH 1/2] check stat's result and avoid calling stat on a NULL pointer, Benno Schulenberg, 2016/02/06