tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: MAXPATHLEN vs PATH_MAX
Le Sun, May 28, 2023 at 06:26:44AM +0000, David Holland a écrit :
>
> Also, I'm not sure everyone agrees with you on that distinction of
> "size" and "length" (even though it makes a certain amount of sense)
> so be careful about drawing too many conclusions.
>
For this, it's simply, for me, C:
char string[];
the difference between strlen(string) and sizeof string.
And for the ones who could think that I'm beating around the bush,
stumbling now and then on something at random, no: like in the Dupin
Poe's first novel, once you have the... path, it's clear why you ended
there:
I wanted to use the jemalloc debugging features. But it is not on by
default in libc, while jemalloc is the alloc engine now. I then wanted
to LD_PRELOAD an ad hoc compiled version: the program crashed in ld.elf_so.
So I started to look at the code of the rtld and saw that LD_PRELOAD was
taking a list of libraries using strsep(3) to tokenize (on both column and
space). Well, I use strtok(3) or an hand made variant, so I looked what
strsep(3) was doing differently from strtok(3).
About its features is the ability to detect "empty fields". Uh? But what
will give an empty string library name?
My first reaction was: "obviously" an empty string will fail. But I'm
always suspicious when I answer: "obviously". It's generally because I
never thought of any reason.
So I take K&R and look for fopen(3): the empty string is not mentionned.
Uh...
So I take POSIX for open(2): the empty string is not mentionned clearly
either but, distilling the mandatory errors, it seems that an empty
string could be used for a directory (but converted to CWD) but could
not be used for a filename. But I'm unsure of my interpretation.
So I look in the NetBSD implementation and look at realpath(), then
stumble on the faulty pathadj().
Having found one bug, the---normal---process is to search if this fault
was not done elsewhere (when I find a fault in my code, I review all my
code to see if I have not done the same fault---or another one...---for the
same thing elsewhere).
Then I find what I think is a nest of bugs in inetd.
Going back to realpath(), I see that it uses MAXPATHLEN while PATH_MAX
is defined by NetBSD and is used in the 2018 version of POSIX. So I look
the definition of MAXPATHLEN to see if there can be a hiatus...
--
Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
http://www.kergis.com/
http://kertex.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89 250D 52B1 AE95 6006 F40C
Home |
Main Index |
Thread Index |
Old Index