Re: segfault and uid problem

Michael Schroeder <[email protected]>
Newsgroups gmane.comp.gnu.screen
Message-ID <[email protected]>
On Sun, Feb 15, 2004 at 03:14:43PM -0500, Hendrik Scholz wrote:
> Reading the make output and the strncpy/strerror manpages it becomes 
> pretty
> much evident that string.h has to be included:
> 
> --- screen.c.orig       Sun Feb 15 14:49:28 2004
> +++ screen.c    Sun Feb 15 14:50:16 2004
> @@ -35,6 +35,10 @@
> 
>   #include <fcntl.h>
> 
> +#ifdef __FreeBSD__
> +#include <string.h>
> +#endif
> +

This should be done in os.h. I guess SVR4 is not defined in config.h,
is it ok to include both "strings.h" and "string.h" on FreeBSD?

> @@ -1906,7 +1910,7 @@
>         p += strlen(p);
>         *p++ = ':';
>         *p++ = ' ';
> -      strncpy(p, strerror(err), buf + sizeof(buf) - p - 1);
> +      strncpy(p, (char *)strerror(err), buf + sizeof(buf) - p - 1);
>         buf[sizeof(buf) - 1] = 0;
>       }
>     debug2("Msg('%s') (%#x);\n", buf, (unsigned int)display);
> @@ -1960,7 +1964,7 @@
>         p += strlen(p);
>         *p++ = ':';
>         *p++ = ' ';
> -      strncpy(p, strerror(err), buf + sizeof(buf) - p - 1);
> +      strncpy(p, (char *)strerror(err), buf + sizeof(buf) - p - 1);
>         buf[sizeof(buf) - 1] = 0;
>       }
>     debug3("Panic('%s'); display=%x displays=%x\n", buf, display, 
> displays);

These casts don't make sense, they are not needed if strerror() is
declared to return (char *) and don't help if the compiler thinks
strerror() returns an int.

> Once correctly patched screen doesn't core dump but prints:
> [0.20] root@slurmcan:~ > screen
> /tmp/screens/S-root/89382.ttyp3.slurmcan: No such file or directory
> [0.20] root@slurmcan:~ >

Yes, that's normal. You have to use "screen -m" in that case, because
otherwise screen tries to create a new window in the running screen
and fails to connect to the socket/pipe. We could check the socketname
for an uid mismatch, though...

Cheers,
  Michael.

-- 
Michael Schroeder           [email protected]
main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);}


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/gnu-screen/

<*> To unsubscribe from this group, send an email to:
     [email protected]

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.