Lines 28-40
Link Here
|
28 |
#include <sys/types.h> |
28 |
#include <sys/types.h> |
29 |
#include <sys/socket.h> |
29 |
#include <sys/socket.h> |
30 |
#include <sys/un.h> |
30 |
#include <sys/un.h> |
31 |
#include <sys/syslog.h> |
|
|
32 |
#include <sys/time.h> |
31 |
#include <sys/time.h> |
33 |
#include <sys/sysctl.h> |
|
|
34 |
|
35 |
#ifndef _PATH_LOG |
36 |
#define _PATH_LOG "/dev/log" |
37 |
#endif |
38 |
|
32 |
|
39 |
#ifdef __PROPOLICE_BLOCK_SEGV__ |
33 |
#ifdef __PROPOLICE_BLOCK_SEGV__ |
40 |
#define SSP_SIGTYPE SIGSEGV |
34 |
#define SSP_SIGTYPE SIGSEGV |
Lines 50-74
void
Link Here
|
50 |
__guard_setup (void) |
44 |
__guard_setup (void) |
51 |
{ |
45 |
{ |
52 |
size_t size; |
46 |
size_t size; |
53 |
#ifdef HAVE_DEV_ERANDOM |
|
|
54 |
int mib[3]; |
55 |
#endif |
56 |
|
57 |
if (__guard != 0UL) |
47 |
if (__guard != 0UL) |
58 |
return; |
48 |
return; |
59 |
|
49 |
|
60 |
#ifndef __SSP_QUICK_CANARY__ |
50 |
#ifndef __SSP_QUICK_CANARY__ |
61 |
#ifdef HAVE_DEV_ERANDOM |
|
|
62 |
/* Random is another depth in Linux, hence an array of 3. */ |
63 |
mib[0] = CTL_KERN; |
64 |
mib[1] = KERN_RANDOM; |
65 |
mib[2] = RANDOM_ERANDOM; |
66 |
|
67 |
size = sizeof (unsigned long); |
68 |
if (__sysctl (mib, 3, &__guard, &size, NULL, 0) != (-1)) |
69 |
if (__guard != 0UL) |
70 |
return; |
71 |
#endif |
72 |
/* |
51 |
/* |
73 |
* Attempt to open kernel pseudo random device if one exists before |
52 |
* Attempt to open kernel pseudo random device if one exists before |
74 |
* opening urandom to avoid system entropy depletion. |
53 |
* opening urandom to avoid system entropy depletion. |
Lines 109-121
__stack_smash_handler (char func[], int
Link Here
|
109 |
const char message[] = ": stack smashing attack in function "; |
88 |
const char message[] = ": stack smashing attack in function "; |
110 |
int bufsz, len; |
89 |
int bufsz, len; |
111 |
char buf[512]; |
90 |
char buf[512]; |
112 |
#ifndef __dietlibc__ |
|
|
113 |
struct sockaddr_un sock; /* AF_UNIX address of local logger */ |
114 |
int log; |
115 |
extern char *__progname; |
116 |
#else |
117 |
static char *__progname = "dietapp"; |
91 |
static char *__progname = "dietapp"; |
118 |
#endif |
|
|
119 |
|
92 |
|
120 |
sigset_t mask; |
93 |
sigset_t mask; |
121 |
sigfillset (&mask); |
94 |
sigfillset (&mask); |
Lines 144-161
__stack_smash_handler (char func[], int
Link Here
|
144 |
/* print error message */ |
117 |
/* print error message */ |
145 |
write (STDERR_FILENO, buf + 3, len - 3); |
118 |
write (STDERR_FILENO, buf + 3, len - 3); |
146 |
write (STDERR_FILENO, "()\n", 3); |
119 |
write (STDERR_FILENO, "()\n", 3); |
147 |
#ifndef __dietlibc__ |
|
|
148 |
if ((log = socket (AF_UNIX, SOCK_DGRAM, 0)) != -1) |
149 |
{ |
150 |
/* Send "found" message to the "/dev/log" path */ |
151 |
sock.sun_family = AF_UNIX; |
152 |
(void) strncpy (sock.sun_path, _PATH_LOG, sizeof (sock.sun_path) - 1); |
153 |
sock.sun_path[sizeof (sock.sun_path) - 1] = '\0'; |
154 |
sendto (log, buf, len, 0, (struct sockaddr *) &sock, sizeof (sock)); |
155 |
} |
156 |
#endif |
157 |
/* Make sure the default handler is associated with the our signal handler */ |
158 |
|
120 |
|
|
|
121 |
/* Make sure the default handler is associated with the our signal handler */ |
159 |
memset (&sa, 0, sizeof (struct sigaction)); |
122 |
memset (&sa, 0, sizeof (struct sigaction)); |
160 |
sigfillset (&sa.sa_mask); /* Block all signals */ |
123 |
sigfillset (&sa.sa_mask); /* Block all signals */ |
161 |
sa.sa_flags = 0; |
124 |
sa.sa_flags = 0; |