Cc Jonathan and linux-doc
On (06/24/15 23:03), Greg KH <[email protected]>
([email protected]) wrote:
[..]
> > > -- show() should always use scnprintf().
> > > +- show() must not use snprintf() when formatting a value to be
> > > + returned to user space. For small single values you can use
> > > + sprintf() otherwise you must use scnprintf().
> >
> > Well, a single value can easily overflow
> >
> > sprintf(buf, "%s", dev->large_value);
>
> That's an obviously foolish sysfs attribute, if you do that, you deserve
> the kernel crash :)
:)
And the 'always use scnprintf()' rule keeps all of us on the safe
side (almost for free).
> > Probably the wording better be "if you guarantee that overflow will
> > never happen, then you can use ...".
>
> For a document that no one has obviously read in the past 5 years, I
> really doubt we need to work too hard on the exact specific wording of
> it.
Oh, it's especially pleasant and satisfactory to ignore
a well-written and scrupulous documentation :) just kidding.
-ss
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html