On Sat, Dec 17, 2011 at 06:08:48PM +0800, Paul Wise wrote: > On Fri, Dec 16, 2011 at 9:00 AM, Russ Allbery wrote: > > I haven't looked at the patch in this thread, but most of the time that > > I've seen PATH_MAX used in software, it's indicated a design flaw in an > > interface: use of static buffers for file paths rather than adjusting to > > arbitrary length of file names. You can arguably "fix" it by defining > > PATH_MAX to something arbitrary, but usually the better fix is to go back > > and fix the incorrect choice of API to use a caller-provided buffer or to > > do memory allocation instead. > > I tend to see upstreams defining their own PATH_MAX rather than > calling pathconf.
Which is just as bad.
Here's the entire code for pathconf(_PC_PATH_MAX):
------------------------------------------------
long int
__pathconf (const char *path, int name)
{
switch (name)
{
[...]
case _PC_PATH_MAX:
#ifdef PATH_MAX
return PATH_MAX;
#else
return -1;
#endif
------------------------------------------------
> Perhaps there needs to be a lintian warning about that.
It's easy to find uses of pathconf, finding PATH_MAX would be hard since it
tends to be heavily #ifdefed. Still, any reference to either is most likely
a bug.
--
1KB // Yo momma uses IPv4!
signature.asc
Description: Digital signature

