Justus Winter, le Sat 01 Feb 2014 16:34:20 +0100, a écrit : > Quoting Samuel Thibault (2014-02-01 15:20:55) > > Justus Winter, le Sat 01 Feb 2014 15:09:21 +0100, a écrit : > > > The name field is not necessarily zero-terminated. Use a precision > > > argument to limit the number of characters written when printing the > > > name. > > > > Mmm, I'd probably rather see the name field always be zero-terminated, > > since that's just one place, vs the various places which would want to > > print it. > > I thought about doing that. But that would waste one character just > for the termination.
That's little compared to security :) > GNU Machs printf implementation supports strings with the precision > given as argument: > > printf ("%.*s", sizeof foo->name, foo->name); > > I think thats clean, concise and easy to use. But people would tend to forget doing it. We can't really fight that. Samuel