Re: [PATCH] Fix unterminated buffer after readlink() call
- From: Thomas Jarosch <thomas jarosch intra2net com>
- To: Dan Williams <dcbw redhat com>
- Cc: networkmanager-list gnome org
- Subject: Re: [PATCH] Fix unterminated buffer after readlink() call
- Date: Mon, 17 Oct 2011 16:13:04 +0200
On Friday, 14. October 2011 17:50:14 Dan Williams wrote:
> > Good catch, I missed the memset() call.
> >
> > And if readlink() doesn't fill the buffer,
> >
> > > the remaining bytes will already be set to 0 by the memset, AFAICT.
> > > Are you seeing a crash here or was this from visual inspection?
> >
> > Pure visual inspection, I was looking for readlink() usage patterns.
> >
> > Still the buf[link_len] = '0'; is more explicit and we wouldn't need
> > the memset() call at all. What do you think?
>
> I try to do the memset() calls specifically to prevent bugs caused by
> forgetting to do NULL termination later on; it's kind of the shotgun
> approach but these paths generally aren't performance sensitive and I
> think the tradeoff of a few cycles to memset (which is a very optimized
> operation these days) is worth the decreased possibility of bugs and
> buffer overruns here. At least that was my thought :)
Yeah, performance is not an issue here. So let's keep it like it is.
Cheers,
Thomas
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]