bug-xboard
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-XBoard] [bug #31634] Bad path results in segmentation fault


From: Adrian Petrescu
Subject: Re: [Bug-XBoard] [bug #31634] Bad path results in segmentation fault
Date: Fri, 12 Nov 2010 15:18:28 -0800

I believe the "~" shorthand is something that the shells expand, not something the kernel inherently knows about. Indeed, I doubt the kernel knows anything about something that high-level at all. But there may be  some standard function to do this translation.

Cheers,
Adrian

On Fri, Nov 12, 2010 at 2:37 PM, h.g. muller <address@hidden> wrote:
I don't think this is the correct patch.

The true problem is the *strchr(buf, '/') = 0; statement in the else part.
This assumes that in any pathname starting with ~ there will be a slash,
and causes the segfault if there is none. The patch merely diverts control
to the else part in case there happens to be a space after the ~,
but there are plenty cases with neither space nor slash, and they would
keep segfaulting.

I am a bit surprised to find this code anyway: I am not a Linux man, and
I thought that ~ was a standard filename convention handled by the kernel,
like it handles / as root. I was not aware that every application has to make
the translation to home directory by itself. Yet this is what the code seems
to be for.

If this code indeed has to be kept, the proper solution would be to skip
the assignment if there is no /, i.e.

{ char *p; if(p = strchr(buf, '/')) *p = 0; }
_______________________________________________
Bug-XBoard mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/bug-xboard


reply via email to

[Prev in Thread] Current Thread [Next in Thread]