[hobbit] Coredump when generating pre-built reports

Frédéric Mangeant frederic.mangeant at steria.com
Fri Dec 2 17:27:37 CET 2005


Henrik Stoerner a écrit :
> I suspect this is somewhat the same problem both of you are seeing.
> Could you try the attached patch and let me know if it helps ?
>   

Hi Henrik

thanks for the patch, however I cannot appy it :

$ patch -p0 < /tmp/hobbit-4.1.2p1-history.patch
patching file bbdisplay/reportdata.c
Hunk #1 FAILED at 11.
Hunk #2 FAILED at 304.
Hunk #3 FAILED at 414.
Hunk #4 FAILED at 506.
Hunk #5 FAILED at 518.
5 out of 5 hunks FAILED -- saving rejects to file bbdisplay/reportdata.c.rej


$ cat bbdisplay/reportdata.c.rej
***************
*** 11,17 ****
  
/*                                                                            
*/
  
/*----------------------------------------------------------------------------*/

- static char rcsid[] = "$Id: reportdata.c,v 1.36 2005/05/02 10:30:12 
henrik Exp $";

  #include <limits.h>
  #include <stdio.h>
--- 11,17 ----
  
/*                                                                            
*/
  
/*----------------------------------------------------------------------------*/

+ static char rcsid[] = "$Id: reportdata.c,v 1.37 2005/12/02 16:03:45 
henrik Exp $";

  #include <limits.h>
  #include <stdio.h>
***************
*** 304,326 ****
  static char *timename(char *timestring)
  {
        static char timespec[26];
-
-       char timecopy[26];
-       char *token;
        int i;

        /* Compute the timespec string used as the name of the 
historical logfile */
-       strncpy(timecopy, timestring, 25);
-       timecopy[25] = '\0';
-
-       token = strtok(timecopy, " ");
-       strcpy(timespec, token);
-
-       for (i=1; i<5; i++) {
-               strcat(timespec, "_");
-               token = strtok(NULL, " ");
-               strcat(timespec, token);
        }

        return timespec;
  }
--- 304,330 ----
  static char *timename(char *timestring)
  {
        static char timespec[26];
+       char *timecopy;
+       char *tokens[5];
        int i;

        /* Compute the timespec string used as the name of the 
historical logfile */
+       *timespec = '\0';
+       timecopy = strdup(timestring);
+       tokens[0] = tokens[1] = tokens[2] = tokens[3] = tokens[4] = NULL;
+
+       tokens[0] = strtok(timecopy, " "); i = 0;
+       while (tokens[i] && (i < 4)) { i++; tokens[i] = strtok(NULL, " "); }
+
+       if (tokens[4]) {
+               /* Got all 5 elements */
+               snprintf(timespec, sizeof(timespec), "%s_%s_%s_%s_%s",
+                        tokens[0], tokens[1], tokens[2], tokens[3], 
tokens[4]);
        }
+       else {
+               errprintf("Bad timespec in history file: %s\n", timestring);
+       }
+       xfree(timecopy);

        return timespec;
  }
***************
*** 410,421 ****
                                newentry->color = color;
                                newentry->affectssla = (reporttime && 
(sladuration > 0));

-                               if (!for_history && (color != COL_GREEN)) {
                                        newentry->cause = 
parse_histlogfile(hostname, servicename, timespec);
                                }
                                else newentry->cause = "";

-                               newentry->timespec = strdup(timespec);
                                newentry->next = reploghead;
                                reploghead = newentry;
                        }
--- 414,425 ----
                                newentry->color = color;
                                newentry->affectssla = (reporttime && 
(sladuration > 0));

+                               if (!for_history && timespec && (color 
!= COL_GREEN)) {
                                        newentry->cause = 
parse_histlogfile(hostname, servicename, timespec);
                                }
                                else newentry->cause = "";

+                               newentry->timespec = (timespec ? 
strdup(timespec): NULL);
                                newentry->next = reploghead;
                                reploghead = newentry;
                        }
***************
*** 502,508 ****
        time_t duration;
        char colstr[MAX_LINE_LEN];
        int color;

        fileerrors = scan_historyfile(fd, snapshot, snapshot,
                                      l, sizeof(l), starttime, 
&duration, colstr);

--- 506,514 ----
        time_t duration;
        char colstr[MAX_LINE_LEN];
        int color;
+       char *p;

+       *histlogname = NULL;
        fileerrors = scan_historyfile(fd, snapshot, snapshot,
                                      l, sizeof(l), starttime, 
&duration, colstr);

***************
*** 512,518 ****
                color = -2;
        }

-       *histlogname = strdup(timename(l));

        return color;
  }
--- 518,525 ----
                color = -2;
        }

+       p = timename(l);
+       if (p) *histlogname = strdup(p);

        return color;
  }


-- 

Frédéric Mangeant

Steria EDC Sophia-Antipolis






More information about the Xymon mailing list