Skip to contentSkip to conversation

Use PATH_MAX for pathname char arrays.

DISCUSSION Samuel Thibault 2 participants 3 messages Apr 4, 2008

lore
Share & tools
lore
#0 lore raw

Hello,

Using PATH_MAX is not a good idea: POSIX says that that definition is facultative, in case the system does not impose any limit on path length. Some systems may also set PATH_MAX to a quite high value, and we would hence consume a lot of stack.

Samuel

#1 lore raw

If there are better alternatives I'd be happy to use them instead. But we already use PATH_MAX elsewhere in the tools, so this might be a wider-ranging cleanup than you think. The original impetus for this change was due to bugchecks applied in some cases by glibc's realpath() implementation. But actually is realpath() deprecated anyway?

-- Keir

Quoted 13 lines · Samuel Thibault

Hello,

Using PATH_MAX is not a good idea: POSIX says that that definition is facultative, in case the system does not impose any limit on path length. Some systems may also set PATH_MAX to a quite high value, and we would hence consume a lot of stack.

Samuel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw
Quoted 3 lines · Keir Fraser, le Fri 04 Apr 2008 15:30:52 +0100, a écrit :

If there are better alternatives I'd be happy to use them instead. But we already use PATH_MAX elsewhere in the tools, so this might be a wider-ranging cleanup than you think.

That's possible indeed, I'm just making sure we try to avoid adding others :)

Quoted 3 lines

The original impetus for this change was due to bugchecks applied in some cases by glibc's realpath() implementation.
But actually is realpath() deprecated anyway?

Ah, right, realpath has a bad semantic indeed. The intent of SUS is to have it allocate the string if NULL is given, but that's not necessarily implemented yet. In the wild, I only know GNU/Hurd which doesn't have any PATH_MAX limit, and it happens that that one has the allocation behavior.

Samuel