[hobbit] bbhostshow segfaults...
Henrik Stoerner
henrik at hswn.dk
Wed Jun 7 22:44:35 CEST 2006
On Wed, Jun 07, 2006 at 09:39:19PM +0200, Kolbjørn Barmen wrote:
>
> .. if bb-hosts has "directory" entries.
>
> Works fine with "include" entries.
>
> Hopefully reproduceable elsewhere as well :)
Very reproducible. Patch attached.
Henrik
-------------- next part --------------
--- lib/stackio.c 2006/05/03 21:12:33 1.18
+++ lib/stackio.c 2006/06/07 20:42:15
@@ -11,7 +11,7 @@
/* */
/*----------------------------------------------------------------------------*/
-static char rcsid[] = "$Id: stackio.c,v 1.18 2006/05/03 21:12:33 henrik Exp $";
+static char rcsid[] = "$Id: stackio.c,v 1.19 2006/06/07 20:42:14 henrik Exp $";
#include <sys/types.h>
#include <sys/stat.h>
@@ -327,7 +327,6 @@
static void addtofnlist(char *dirname, void **v_listhead)
{
filelist_t **listhead = (filelist_t **)v_listhead;
- filelist_t *newlistitem;
DIR *dirfd;
struct dirent *d;
struct stat st;
@@ -344,13 +343,17 @@
}
/* Add the directory itself to the list of files we watch for modifications */
- stat(dirfn, &st);
- newlistitem = (filelist_t *)malloc(sizeof(filelist_t));
- newlistitem->filename = strdup(dirfn);
- newlistitem->mtime = st.st_mtime;
- newlistitem->fsize = 0; /* We dont check sizes of directories */
- newlistitem->next = *listhead;
- *listhead = newlistitem;
+ if (listhead) {
+ filelist_t *newlistitem;
+
+ stat(dirfn, &st);
+ newlistitem = (filelist_t *)malloc(sizeof(filelist_t));
+ newlistitem->filename = strdup(dirfn);
+ newlistitem->mtime = st.st_mtime;
+ newlistitem->fsize = 0; /* We dont check sizes of directories */
+ newlistitem->next = *listhead;
+ *listhead = newlistitem;
+ }
while ((d = readdir(dirfd)) != NULL) {
int fnlen = strlen(d->d_name);
More information about the Xymon
mailing list