From b3d624076cc536803c73c48cc543bfb6b5ef94d2 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Wed, 26 Jun 2013 15:10:55 +0200 Subject: Fix 10123 --- crash/10123.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/crash/10123.c b/crash/10123.c index 48a9304..b7c30a9 100644 --- a/crash/10123.c +++ b/crash/10123.c @@ -1,9 +1,13 @@ /* *Excerpt of the bug's description: - GDB fails to interrupt the program being debugged if the program is blocking SIGINT. + GDB fails to interrupt the program being debugged if the program is blocking SIGINT. - When using the sigwait function to retrieve signals, the program is expected to block them. SIGINT is a commonly handled signal. Any - program using sigwait to retrieve signals and handling SIGINT this way will not be interruptible by GDB. + When using the sigwait function to retrieve signals, + the program is expected to block them. SIGINT is a commonly handled signal. + + Any program using sigwait to retrieve signals and handling SIGINT this way will not be interruptible by GDB. + +The dectection process used here is the SIGTRAP trick. Fell free to use another one. */ #include @@ -11,22 +15,25 @@ #include #include +void no_gdb(int s){ + signal(SIGTRAP, SIG_DFL); + printf("[*] No GBD detected\n"); + /* + * Put your code here + */ + _exit(0); +} + int main(){ + signal(SIGTRAP, &no_gdb); sigset_t sigs; - sigfillset(&sigs); - sigprocmask(SIG_SETMASK, &sigs, NULL); - - if(fork()){ - sleep(1); // to be sure that - kill(getppid(), SIGINT); - _exit(0); - } - while(1){ - pause(); - printf("[*] No GBD detected\n"); - /* - * Put your code here - */ - } + sigemptyset(&sigs); + sigaddset(&sigs, SIGINT); + sigprocmask(SIG_BLOCK, &sigs, NULL); + + raise(SIGTRAP); + + printf("[*] GDB detected\n"); + while(1); return 0; } -- cgit v1.3