From: <st...@us...> - 2012-07-28 06:30:01
|
Revision: 7129 http://xymon.svn.sourceforge.net/xymon/?rev=7129&view=rev Author: storner Date: 2012-07-28 06:29:55 +0000 (Sat, 28 Jul 2012) Log Message: ----------- showgraph: Rev7128 from 4.3.10: Missing check for failure to access $XYMONTMP directory could cause a crash. Revision Links: -------------- http://xymon.svn.sourceforge.net/xymon/?rev=7128&view=rev Modified Paths: -------------- trunk/web/showgraph.c Modified: trunk/web/showgraph.c =================================================================== --- trunk/web/showgraph.c 2012-07-28 06:29:24 UTC (rev 7128) +++ trunk/web/showgraph.c 2012-07-28 06:29:55 UTC (rev 7129) @@ -128,9 +128,6 @@ struct dirent *d; int ctlsocket = -1; - req = (char *)malloc(strlen(hostname)+3); - sprintf(req, "/%s/", hostname); - ctlsocket = socket(AF_UNIX, SOCK_DGRAM, 0); if (ctlsocket == -1) { errprintf("Cannot get socket: %s\n", strerror(errno)); @@ -139,6 +136,14 @@ fcntl(ctlsocket, F_SETFL, O_NONBLOCK); dir = opendir(xgetenv("XYMONTMP")); + if (!dir) { + errprintf("Cannot acces $XYMONTMP directory: %s\n", strerror(errno)); + return; + } + + req = (char *)malloc(strlen(hostname)+3); + sprintf(req, "/%s/", hostname); + while ((d = readdir(dir)) != NULL) { if (strncmp(d->d_name, "rrdctl.", 7) == 0) { struct sockaddr_un myaddr; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |