Unix VM alias resolving bug

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Unix VM alias resolving bug

Henrik Sperre Johansen

There's a bug in the alias resolution sqGetFilenameFromString in sqUnixMain.c

In the line
filenameLength = readLink(aCharBuffer, aCharBuffer, MAXPATHLEN)
It replaces the old link path with the resolved link path, however links may be relative, eg. /bin/sh linking to bash rather than /bin/bash.

Thus, file opening, and other operations using this function will fail if encountering a relative link.

F.ex. print (on Ubuntu, where sh -> dash):

 |openedRelative|
openedRelative := nil.
[FileStream readOnlyFileNamed: '/bin/sh' do: [:fs | openedRelative := true]] on: FileDoesNotExistException do: [openedRelative := false].
openedRelative

and you get false.

Cheers,
Henry
Reply | Threaded
Open this post in threaded view
|

Re: Unix VM alias resolving bug

Bert Freudenberg


On 24.06.2010, at 19:30, Henrik Johansen wrote:

>
> There's a bug in the alias resolution sqGetFilenameFromString in sqUnixMain.c
>
> In the line
> filenameLength = readLink(aCharBuffer, aCharBuffer, MAXPATHLEN)
> It replaces the old link path with the resolved link path, however links may be relative, eg. /bin/sh linking to bash rather than /bin/bash.
>
> Thus, file opening, and other operations using this function will fail if encountering a relative link.
>
> F.ex. print (on Ubuntu, where sh -> dash):
>
> |openedRelative|
> openedRelative := nil.
> [FileStream readOnlyFileNamed: '/bin/sh' do: [:fs | openedRelative := true]] on: FileDoesNotExistException do: [openedRelative := false].
> openedRelative
>
> and you get false.
>
> Cheers,
> Henry

Yeah I've been bitten by that too. Do you have a patch? Actually, Ian prefers to be sent a fully patched file ...

- Bert -


Reply | Threaded
Open this post in threaded view
|

Re: Unix VM alias resolving bug

Eliot Miranda-2
 


On Thu, Jun 24, 2010 at 10:33 AM, Bert Freudenberg <[hidden email]> wrote:


On 24.06.2010, at 19:30, Henrik Johansen wrote:

>
> There's a bug in the alias resolution sqGetFilenameFromString in sqUnixMain.c
>
> In the line
> filenameLength = readLink(aCharBuffer, aCharBuffer, MAXPATHLEN)
> It replaces the old link path with the resolved link path, however links may be relative, eg. /bin/sh linking to bash rather than /bin/bash.
>
> Thus, file opening, and other operations using this function will fail if encountering a relative link.
>
> F.ex. print (on Ubuntu, where sh -> dash):
>
> |openedRelative|
> openedRelative := nil.
> [FileStream readOnlyFileNamed: '/bin/sh' do: [:fs | openedRelative := true]] on: FileDoesNotExistException do: [openedRelative := false].
> openedRelative
>
> and you get false.
>
> Cheers,
> Henry

Yeah I've been bitten by that too. Do you have a patch? Actually, Ian prefers to be sent a fully patched file ...

You'll find its fixed in the Cog sources.  Alas there are other changes there-in, but at least that function is not affected by other changes.
 

- Bert -



Reply | Threaded
Open this post in threaded view
|

Re: Unix VM alias resolving bug

Henrik Sperre Johansen
 
On Jun 24, 2010, at 7:49 46PM, Eliot Miranda wrote:



On Thu, Jun 24, 2010 at 10:33 AM, Bert Freudenberg <[hidden email]> wrote:


On 24.06.2010, at 19:30, Henrik Johansen wrote:

>
> There's a bug in the alias resolution sqGetFilenameFromString in sqUnixMain.c
>
> In the line
> filenameLength = readLink(aCharBuffer, aCharBuffer, MAXPATHLEN)
> It replaces the old link path with the resolved link path, however links may be relative, eg. /bin/sh linking to bash rather than /bin/bash.
>
> Thus, file opening, and other operations using this function will fail if encountering a relative link.
>
> F.ex. print (on Ubuntu, where sh -> dash):
>
> |openedRelative|
> openedRelative := nil.
> [FileStream readOnlyFileNamed: '/bin/sh' do: [:fs | openedRelative := true]] on: FileDoesNotExistException do: [openedRelative := false].
> openedRelative
>
> and you get false.
>
> Cheers,
> Henry

Yeah I've been bitten by that too. Do you have a patch? Actually, Ian prefers to be sent a fully patched file ...

You'll find its fixed in the Cog sources.  Alas there are other changes there-in, but at least that function is not affected by other changes.
 

- Bert -



Thanks!

Attached is the sqUnixMain.c from 2202 release, with the function modified as has been done in Cog.
I built using it, and verified the expression in previous mail now returns true.

Cheers,
Henry



sqUnixMain.c (42K) Download Attachment