Source-Changes-D archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: CVS commit: src/lib/libwrap
On Jan 11, 7:39am, kre%munnari.OZ.AU@localhost (Robert Elz) wrote:
-- Subject: Re: CVS commit: src/lib/libwrap
| | PR/53851: Andreas Gustafsson: libwrap prints "m" instead of errno
| | Handle %m inline if needed, otherwise vasprintf strips the %m and...
|
| That change handles the simple case of %m but fails on %%m (though
| that is, I assume, unlikely, in libwrap error messages).
This is not intended to be a general solution. In fact it is a compromise:
I thought of changing all %m's to %s, strerror(errno) in the messages and
I decided that it was more intrusive than the simplistic change.
| The simple change, making the test be ...
|
| if ((ptr = strstr(fmt, "%m")) != NULL &&
| (ptr == fmt || ptr[-1] != '%'))
|
| fails on %%%m (though I would guess that is even less likely).
|
| There's no good way to correctly fix this using this technique, what
| is needed is to do as the syslog() functions do, and actually do a
| (restricted) parse of the format string.
I understand, this is why I grepped the source for %m and saw that there
was no use other than " %m\0".
| For this though, I suspect it would be overkill. The point of this message
| is just to make sure everyone is aware of this, and perhaps, if there is
| some suitable place to document it, that that be done.
Yes, the perfect being the enemy of the good.
| Oh for the ability to simply add application specific format specifiers
| to printf - I think plan9 has something along those lines. It would be
| farily easy to add, if only gcc didn't go and do printf format string
| analysis and complain when it sees something it does not understand.
Yes, that is something I wished for many times. But then there are
trade-offs (such as compile time checking) and other safety guarantees.
christos
Home |
Main Index |
Thread Index |
Old Index