[PATCH] powerpc: fix i2c device string format

Paul Mackerras paulus at samba.org
Wed Aug 15 16:23:17 EST 2007


Guennadi Liakhovetski writes:

> On Thu, 9 Aug 2007, Segher Boessenkool wrote:
> 
> > > > strncpy() won't put a terminating zero on there, is everything
> > > > that uses the resulting string okay with that?  Also, if the
> > > > name gets cut short, it might match some _other_ expected name.
> > > 
> > > On Wed, 1 Aug 2007, Scott Wood wrote:
> > > 
> > > > You could use strlcpy() instead, which always leaves a zero terminator.
> > > 
> > > The patch below does exactly this - uses strlcpy() to guarantee strings in
> > > i2c device type and driver_name fields are 0-terminated.
> > 
> > You're not checking the return values of these calls.  This would
> > be a good function to put attribute warn_unused_result on :-)
> 
> hm... Well, the worst that could happen, if an "evil" programmer defines 
> too long a name, it gets truncated, and then binds to a wrong driver, 
> well, the worst that can happen is that your hardware gets damaged, not a 
> big thing. However, some might disagree, so, below is a new version... 
> Wrap some long lines while at that.

That's not a commit message I can use.  Please repost with an
informative commit message that says what the motivation for the
change is, plus anything other information that would be useful for
someone looking at this in a couple of years' time.

Paul.



More information about the Linuxppc-dev mailing list