Add security fix for a memory allocation error from Mandrake Linux's sysklogd-1.4.1-owl-syslogd-crunch_list.diff (which is from OWL). Bump PKGREVISION.
109 lines
2.7 KiB
Text
109 lines
2.7 KiB
Text
--- syslogd.c.orig 2001-03-11 11:40:10.000000000 -0800
|
|
+++ syslogd.c 2004-05-10 16:05:05.393947560 -0700
|
|
@@ -521,7 +521,8 @@
|
|
#if defined(FSSTND)
|
|
#define _PATH_LOGPID _PATH_VARRUN SYSLOGD_PIDNAME
|
|
#else
|
|
-#define _PATH_LOGPID "/etc/" SYSLOGD_PIDNAME
|
|
+/* #define _PATH_LOGPID "/etc/" SYSLOGD_PIDNAME */
|
|
+#define _PATH_LOGPID _PATH_VARRUN SYSLOGD_PIDNAME
|
|
#endif
|
|
#else
|
|
#ifndef _PATH_LOGPID
|
|
@@ -890,11 +891,11 @@
|
|
dprintf("Checking pidfile.\n");
|
|
if (!check_pid(PidFile))
|
|
{
|
|
+ signal (SIGTERM, doexit);
|
|
if (fork()) {
|
|
/*
|
|
* Parent process
|
|
*/
|
|
- signal (SIGTERM, doexit);
|
|
sleep(300);
|
|
/*
|
|
* Not reached unless something major went wrong. 5
|
|
@@ -1254,30 +1255,26 @@
|
|
crunch_list(list)
|
|
char *list;
|
|
{
|
|
- int count, i;
|
|
+ int i, m, n;
|
|
char *p, *q;
|
|
char **result = NULL;
|
|
|
|
p = list;
|
|
|
|
/* strip off trailing delimiters */
|
|
- while (p[strlen(p)-1] == LIST_DELIMITER) {
|
|
- count--;
|
|
+ while (*p && p[strlen(p)-1] == LIST_DELIMITER)
|
|
p[strlen(p)-1] = '\0';
|
|
- }
|
|
/* cut off leading delimiters */
|
|
- while (p[0] == LIST_DELIMITER) {
|
|
- count--;
|
|
+ while (p[0] == LIST_DELIMITER)
|
|
p++;
|
|
- }
|
|
|
|
- /* count delimiters to calculate elements */
|
|
- for (count=i=0; p[i]; i++)
|
|
- if (p[i] == LIST_DELIMITER) count++;
|
|
+ /* count delimiters to calculate the number of elements */
|
|
+ for (n = i = 0; p[i]; i++)
|
|
+ if (p[i] == LIST_DELIMITER) n++;
|
|
|
|
- if ((result = (char **)malloc(sizeof(char *) * count+2)) == NULL) {
|
|
+ if ((result = (char **)malloc(sizeof(char *) * (n + 2))) == NULL) {
|
|
printf ("Sorry, can't get enough memory, exiting.\n");
|
|
- exit(0);
|
|
+ exit(1);
|
|
}
|
|
|
|
/*
|
|
@@ -1285,30 +1282,28 @@
|
|
* characters are different from any delimiters,
|
|
* so we don't have to care about this.
|
|
*/
|
|
- count = 0;
|
|
- while ((q=strchr(p, LIST_DELIMITER))) {
|
|
- result[count] = (char *) malloc((q - p + 1) * sizeof(char));
|
|
- if (result[count] == NULL) {
|
|
+ m = 0;
|
|
+ while ((q = strchr(p, LIST_DELIMITER)) && m < n) {
|
|
+ result[m] = (char *) malloc((q - p + 1) * sizeof(char));
|
|
+ if (result[m] == NULL) {
|
|
printf ("Sorry, can't get enough memory, exiting.\n");
|
|
- exit(0);
|
|
+ exit(1);
|
|
}
|
|
- strncpy(result[count], p, q - p);
|
|
- result[count][q - p] = '\0';
|
|
+ memcpy(result[m], p, q - p);
|
|
+ result[m][q - p] = '\0';
|
|
p = q; p++;
|
|
- count++;
|
|
+ m++;
|
|
}
|
|
- if ((result[count] = \
|
|
- (char *)malloc(sizeof(char) * strlen(p) + 1)) == NULL) {
|
|
+ if ((result[m] = strdup(p)) == NULL) {
|
|
printf ("Sorry, can't get enough memory, exiting.\n");
|
|
- exit(0);
|
|
+ exit(1);
|
|
}
|
|
- strcpy(result[count],p);
|
|
- result[++count] = NULL;
|
|
+ result[++m] = NULL;
|
|
|
|
#if 0
|
|
- count=0;
|
|
- while (result[count])
|
|
- dprintf ("#%d: %s\n", count, StripDomains[count++]);
|
|
+ m = 0;
|
|
+ while (result[m])
|
|
+ dprintf ("#%d: %s\n", m, result[m++]);
|
|
#endif
|
|
return result;
|
|
}
|