1 diff -ur sysklogd-1.4.1.orig/syslogd.c sysklogd-1.4.1/syslogd.c
2 --- sysklogd-1.4.1.orig/syslogd.c Sun Mar 11 19:40:10 2001
3 +++ sysklogd-1.4.1/syslogd.c Sun Apr 18 01:42:21 2004
4 @@ -1254,30 +1254,26 @@
15 /* strip off trailing delimiters */
16 - while (p[strlen(p)-1] == LIST_DELIMITER) {
18 + while (*p && p[strlen(p)-1] == LIST_DELIMITER)
19 p[strlen(p)-1] = '\0';
21 /* cut off leading delimiters */
22 - while (p[0] == LIST_DELIMITER) {
24 + while (p[0] == LIST_DELIMITER)
28 - /* count delimiters to calculate elements */
29 - for (count=i=0; p[i]; i++)
30 - if (p[i] == LIST_DELIMITER) count++;
31 + /* count delimiters to calculate the number of elements */
32 + for (n = i = 0; p[i]; i++)
33 + if (p[i] == LIST_DELIMITER) n++;
35 - if ((result = (char **)malloc(sizeof(char *) * count+2)) == NULL) {
36 + if ((result = (char **)malloc(sizeof(char *) * (n + 2))) == NULL) {
37 printf ("Sorry, can't get enough memory, exiting.\n");
43 @@ -1285,30 +1281,28 @@
44 * characters are different from any delimiters,
45 * so we don't have to care about this.
48 - while ((q=strchr(p, LIST_DELIMITER))) {
49 - result[count] = (char *) malloc((q - p + 1) * sizeof(char));
50 - if (result[count] == NULL) {
52 + while ((q = strchr(p, LIST_DELIMITER)) && m < n) {
53 + result[m] = (char *) malloc((q - p + 1) * sizeof(char));
54 + if (result[m] == NULL) {
55 printf ("Sorry, can't get enough memory, exiting.\n");
59 - strncpy(result[count], p, q - p);
60 - result[count][q - p] = '\0';
61 + memcpy(result[m], p, q - p);
62 + result[m][q - p] = '\0';
67 - if ((result[count] = \
68 - (char *)malloc(sizeof(char) * strlen(p) + 1)) == NULL) {
69 + if ((result[m] = strdup(p)) == NULL) {
70 printf ("Sorry, can't get enough memory, exiting.\n");
74 - strcpy(result[count],p);
75 - result[++count] = NULL;
80 - while (result[count])
81 - dprintf ("#%d: %s\n", count, StripDomains[count++]);
84 + dprintf ("#%d: %s\n", m, result[m++]);