This is the mail archive of the
libc-alpha@cygnus.com
mailing list for the glibc project.
sigaction in glibc-linuxthreads-2.0.95 with act=NULL segfaults
- To: libc-alpha@cygnus.com
- Subject: sigaction in glibc-linuxthreads-2.0.95 with act=NULL segfaults
- From: aumuelle@mi.uni-erlangen.de
- Date: Wed, 30 Sep 1998 02:05:40 +0200
>Submitter-Id: net
>Originator: Martin Aumueller
>Organization:
>Confidential: no
>Synopsis: sigaction in glibc-linuxthreads-2.0.95 with act=NULL segfaults
>Severity: serious
>Priority: medium
>Category: linuxthreads
>Class: sw-bug
>Release: linuxthreads-2.0.95
>Environment:
Host type: i586-pc-linux-gnu
System: Linux isis 2.1.123 #20 Mon Sep 28 22:20:22 CEST 1998 i586 unknown
Architecture: i586
Addons: crypt linuxthreads
Build CFLAGS: -O2 -g
Build CC: gcc -pipe
Compiler version: pgcc-2.91.57 19980901 (egcs-1.1 release)
Kernel headers: 2.1.123
Symbol versioning: yes
Build static: yes
Build shared: yes
Build pic-default: no
Build profile: no
Build omitfp: no
Build bounded: no
Build static-nss: no
Stdio: libio
>Description:
If sigaction from linuxthreads (in file linuxthreads/signals.c)
gets called with the 2nd parameter as NULL the function segfaults
as there is no test to avoid to access *NULL in line 99 of this file.
<precise description of the problem (multiple lines)>
>How-To-Repeat:
Link the following program with -lpthread:
#include <signal.h>
int main(void) {
sigaction(SIGHUP,0,0);
}
>Fix:
Change the function sigaction to include tests if act==NULL:
int sigaction(int sig, const struct sigaction * act,
struct sigaction * oact)
{
struct sigaction newact;
if (sig == PTHREAD_SIG_RESTART || sig == PTHREAD_SIG_CANCEL)
return EINVAL;
if( act != NULL ) {
newact = *act;
if (act->sa_handler != SIG_IGN && act->sa_handler != SIG_DFL)
newact.sa_handler = pthread_sighandler;
}
if (__sigaction(sig, &newact, oact) == -1)
return -1;
if (oact != NULL) oact->sa_handler = sighandler[sig];
if( act != NULL) sighandler[sig] = act->sa_handler;
return 0;
}