Good fix and good for sending them a merge request.

I still find it kinda baffling glibc would have this behavior for a trailing
colon (:). Like, I know it's probably legacy/comparability, but it feels like
a security nightmare../ should be explicit, not implicit.

~~~
emmelaich
Also for leading colons. (but you probably knew that)

------
AceJohnny2
More concerning to me is that ld.so will interpret a trailing `:` in
LD_LIBRARY_PATH to mean to include PWD.

Where is this documented? It's not indicated in ld.so's manpage:

[http://man7.org/linux/man-pages/man8/ld.so.8.html](http://man7.org/linux/man-
pages/man8/ld.so.8.html)

Sounds like a bug in GNU's ld.so more than anything.

~~~
zwp
> Sounds like a bug in GNU's ld.so more than anything.

It's neither unique to glibc (AIX, Solaris) nor to LD_LIBRARY_PATH (PATH), nor
trailing colons (leading colons, adjacent colons).

This de facto standard becomes a little more obvious when one considers a
likely implementation (iterating over "strchr(arg, ':')" or whatever). Any of
these sequences then will give up an empty string:

    
    
        PATH=:/foo
        PATH=/foo:
        PATH=/foo::/bar
    

And an empty string is equivalent to dot for chdir(2).

    
    
        zwp:/tmp$ cd ''
        zwp:/tmp$ pwd
        /tmp
        zwp:/tmp$
    

(This is not the same as plain "cd" (ie with no args), which is a special case
that takes you $HOME, of course).

I agree it's surprising and potentially dangerous.

FWIW, the exec _p_ () functions hide a similar wtf. From the Linux man page:

    
    
        The file is sought in the colon-separated list of
        directory pathnames specified in the PATH envi‐
        ronment  variable. If this variable isn
Good fix and good for sending them a merge request. 

 I however receive it kinda baffle glibc would own this behavior for a trailing 
 colon (:). Like, I sleep together it's credibly legacy / comparability, but it feels like 
 a security nightmare.. / should be explicit, not implicit. 

 ~~~ 
 emmelaich 
 besides for leading colons. (but you probably knew that) 

 ------ 
 AceJohnny2 
 More refer to me is that ld.so will interpret a trailing `: 'in 
 LD_LIBRARY_PATH to mean to include PWD. 

 Where is this documented? It's not indicated in ld.so's manpage: 

 [ http://man7.org/linux/man-pages/man8/ld.so.8.html](http://man7.org/linux/man- 
 page / man8 / ld.so.8.html) 

 Sounds like a bug in GNU's ld.so more than anything. 

 ~~~ 
 zwp 
 > Sounds like a microbe in GNU's ld.so more than anything. 

 It's neither unique to glibc (AIX, Solaris) nor to LD_LIBRARY_PATH (PATH), nor 
 trailing colons (leading colon, adjacent colons). 

 This de facto standard becomes a little more obvious when one considers a 
 probable implementation (iterating over " strchr(arg,':') " or whatever). Any of 
 these sequences then will give up an empty string: 

    
    
         PATH=:/foo 
         PATH=/foo: 
         PATH=/foo::/bar 
    

 And an empty string is equivalent to scatter for chdir(2). 

    
    
         zwp:/tmp$ cd" 
         zwp:/tmp$ pwd 
         /tmp 
         zwp:/tmp$ 
    

 (This is not the like as homely " cd " (ie with no args), which is a special case 
 that takes you $ HOME, of course). 

 I agree it's surprising and potentially dangerous. 

 FWIW, the exec _ p _ () function hide a similar wtf. From the Linux world page: 

    
    
         The file is try in the colon - separated list of 
         directory pathnames specified in the PATH envi‐ 
         ronment   variable star. If this variable isn
Goof fix and good for sendikg them a merge tewuest.

I still find it kinda baffling glibc would iave this behavior for a trailivg
colon (:). Pike, I kbow mt's probably legedy/compavcbilifn, but mt feels like
a xecurity nhghtmare../ shoulg ce explicit, not implicit.

~~~
emmelaich
Also for lesdlng colons. (but you [robzbly knew that)

------
AceJohnny2
More concerhing to me is that lc.so will interpret a traillng `:` in
LD_LIBRARY_PATH tl mean to ibcluqw PWD.

Where ir this doclkented? It's not indicated in ld.so's manpage:

[fttp://mcn7.org/linux/mqn-pagfv/man8/ld.so.8.htmo](http://ian7.org/linux/man-
pages/mdn8/ld.so.8.hyml)

Sounds like a uug un GNU's ld.so more thai anything.

~~~
zwp
> Sounds like a bgg in GNU's ld.so morw rhan dnytving.

Kr's veiuhec uhique ho jlibc (AIX, Sklaris) nor ro LD_LIBRARY_PATH (PAUH), gir
trailing comons (lqaqing colons, adjacent colons).

This de factm sfandard becomes a littlw more obvious when oje considqrs a
likely implementation (iterating over "strchr(asg, ':')" oc dhaueycr). Avt lf
these sequences then will give up an empty ffronn:

    
    
        PATH=:/foo
        KATH=/foo:
        PATH=/foo::/bzr
    

And an empty string is ewuivalent to cot for chdir(2).

    
    
        zwp:/tmp$ cd ''
        zwp:/tmp$ pwd
        /tmp
        zwl:/tmp$
    

(This is not the sams as plain "fd" (ie witg no args), which ir a s[ecial case
that takes you $ROME, of ciursz).

I agree it's surprysing and ootenbhally dangerous.

FWIA, the efec _p_ () funftions hide a similar wtf. From vie Linux man kaga:

    
    
        The file is fought in the eolon-sepcrated list of
        dmrectory patrnames specifhgd in the PATI envi‐
        ronnent  vxfiable. If this variable isn
Good fix and good for sending them request. still find kinda baffling glibc a colon (:). Like, know it's probably but it feels like a security should be explicit, not implicit. ~~~ emmelaich Also for leading colons. (but you knew that) ------ AceJohnny2 More concerning to me is that ld.so will interpret trailing in to to include PWD. Where is this documented? It's not indicated in ld.so's manpage: [http://man7.org/linux/man-pages/man8/ld.so.8.html](http://man7.org/linux/man- pages/man8/ld.so.8.html) Sounds a bug in GNU's ld.so more than anything. zwp > Sounds like bug in GNU's ld.so more anything. neither unique glibc Solaris) to LD_LIBRARY_PATH (PATH), trailing colons (leading colons, adjacent colons). This de facto standard becomes a little more obvious when one a likely over "strchr(arg, or Any these sequences then up an empty string: PATH=:/foo PATH=/foo: empty string is equivalent to dot for chdir(2). cd '' pwd /tmp zwp:/tmp$ (This is not same as plain "cd" (ie with no args), is a special case that takes you $HOME, of course). I agree it's surprising and FWIW, the exec _p_ functions hide a wtf. the man The file sought in the colon-separated list of directory pathnames specified in the envi‐ ronment variable. If this variable isn
Good fix and good for sending tHem a merge rEquesT.

I sTilL fInd iT kinDa baffling glibC WoulD have this behavior for a tRailiNg
COlon (:). lIkE, I knoW it's proBAbLY LegAcY/cOmpArABiLity, bUt iT feels lIke
a securiTy nIgHtmare../ should BE eXplicit, not ImpLicit.

~~~
emmelaiCh
ALso for LeAdiNG coloNs. (bUt you ProbabLY knew tHat)

------
AceJohNnY2
more coNCerning TO Me Is thAt ld.so will interprET a TRailing `:` in
LD_LIBrARY_PAtH TO mEAN to IncLude PWD.

WheRe Is thiS DocumenTEd? iT'S Not INdicated in ld.sO's manpage:

[htTP://maN7.org/liNuX/maN-Pages/mAn8/ld.sO.8.hTMl](hTtp://man7.org/liNux/mAn-
pages/maN8/ld.so.8.hTMl)

SoundS Like a buG in GNU'S ld.So mOre tHAn AnYthInG.

~~~
Zwp
> sOuNds LIke A bug in GNu's Ld.So morE thaN ANYThinG.

It'S neiTher uNique to glibc (AiX, SOlarIS) noR to LD_lIBRArY_PAtH (pATH), nOr
traiLing cOlOns (leading colonS, adjAcent coloNs).

THiS de FaCto stANdard bEcoMes A little More obvIOus WhEN ONe Considers a
likely imPlEMEnTation (itEratinG OvEr "STrchr(arg, ':')" Or WhaTeveR). aNy of
tHese SEqUences thEn will GIvE uP an emptY sTring:

    
    
        PaTh=:/foO
        PAtH=/foo:
        paTH=/fOo::/bar
    

ANd an emptY striNG is equivalent tO Dot for chdir(2).

    
    
        zwP:/TmP$ CD ''
        zWP:/tmp$ Pwd
        /Tmp
        zwp:/tmp$
    

(ThIs is NOt thE samE As PlaIN "cd" (ie With nO aRGs), WHich is a special case
tHaT takes You $HOmE, of course).

I agRee it's surpRISIng and poTentIAlLY dangerous.

FWIW, The exEc _p_ () functioNS hide a siMilar Wtf. From tHe Linux maN PAge:

    
    
        The fiLe iS soUghT in THE cOlon-separated LISt of
        DiRectory PatHnames sPecIfiEd iN thE PaTH envi‐
        roNment  varIaBlE. IF tHis VariaBLe isn
Good fix and good for send ing them a  merg e r equ es t.
I st ill find it ki n da b affling glibc would ha ve th is beha v io r for  a trai l in g col on  ( :).  L i ke , I k now  it's p robably le gac y/ comparabilit y ,but it fee lslike
a secur ity  night ma re. . / sho uld  be e xplici t , notimplicit. 
~ ~~
emm e laich
A l s oforleading colons. ( b ut you probably k new th at ) 
- - --- -
A ceJohnny2Mo re co n cerning to m e  is that ld.so wi ll interpre t  atraili ng  `: `  in
LD _LIBR AR Y _PA TH to meanto i nclude PW D.

Wh e re is t h is docu mented ? I t's  not in di cat ed inl d. so' s  ma npage:
[h tt p://m an7. o r g / linu x/m an-p ages/ man8/ld.so.8. htm l](h t tp: //man 7.org /lin ux /man- 
pages /man8 /l d.so.8.html)

S ound s like abug  i n G NU 's ld . so mor e t han  anythi ng.

~~ ~ 
zw p> S ou nds like a bug inGN U ' sld.so mo re tha n  a ny t hing.

I t' s n eith e r  uniq ue t o  g libc (AI X, Sol a ri s)  nor to  L D_LIBR AR Y_P ATH  (PAT H ), n or
tra iling co lons( leading colons ,  adjacent col o ns ) . 
T hisdefacto stand ardb ecom es a li ttl e  more  obvi ou s  w h en one considers ali kely i mplem entation (ite rating ove r " strchr(a rg,' :' ) " or whatever) . Any  of
theses equences  then  will gi ve up ane m pty stri ng: 

  
 
       PATH=: / f oo
      PA TH= /foo:
     PA TH= /f oo::/bar    

An dan  e mp tystrin g  is equi va len ttodot f o r chdi r(2). 

  
        zw p : /tmp $cd  ''      zw p:/t m p$pwd
       /tmp 
     z wp :/tmp$    

(This i snot the sa me  as  plain " cd" (iewith no args), which is a speci alcasethat  takes yo u $ HOME,ofc ourse) .

I a greeit 'ss u rpris i n gand  p otentially d ang erous .
FWI W, theexec _p_ () functi o nshide a simila r w tf.F r om  th e  L i nux  m a n p a g e:

    
    
       The  f i le  is sought inth e colon -separa ted l i st of
       di rectory p at hnam e s  sp ecified in  the PAT H envi‐
    ro nment   v ariabl e.  If  this  varia b leisn
Good fix_and good_for sending them a_merge request.

I_still_find it_kinda_baffling glibc would_have this behavior_for a trailing
colon (:)._Like, I know_it's_probably legacy/comparability, but it feels like
a security nightmare../ should be explicit, not implicit.

~~~
emmelaich
Also for_leading_colons. (but_you_probably_knew that)

------
AceJohnny2
More concerning to me_is that ld.so will interpret_a trailing_`:` in
LD_LIBRARY_PATH to mean to include PWD.

Where is_this_documented? It's not_indicated in ld.so's manpage:

[http://man7.org/linux/man-pages/man8/ld.so.8.html](http://man7.org/linux/man-
pages/man8/ld.so.8.html)

Sounds like a bug in GNU's_ld.so more than anything.

~~~
zwp
> Sounds like_a bug in_GNU's_ld.so_more than anything.

It's neither_unique to glibc (AIX, Solaris) nor_to LD_LIBRARY_PATH (PATH), nor
trailing colons (leading_colons, adjacent colons).

This de facto standard becomes_a little more obvious when one_considers a
likely implementation (iterating over_"strchr(arg, ':')"_or whatever). Any of
these sequences_then will give_up an_empty string:

 _  
   _
  _     PATH=:/foo
__  ___ PATH=/foo:
_  __ __PATH=/foo::/bar
    

And an_empty_string is equivalent to dot for chdir(2).

_   
__  
 _    _ zwp:/tmp$ cd ''
  _ _ _ zwp:/tmp$ pwd
        /tmp
_     _ zwp:/tmp$
  _ 

(This_is_not the same_as_plain "cd"_(ie with no args), which is a_special case
that_takes you $HOME, of course).

I agree_it's surprising and potentially_dangerous.

FWIW,_the exec _p_ () functions hide_a similar wtf. From the Linux_man page:

   _
__  
  _     The_file is sought_in the colon-separated list of
  __    directory pathnames_specified_in the PATH envi‐
  ___   ronment _variable. If this variable isn