admserv/cgi-src40/config.c | 14 +-
include/base/file.h | 3
include/base/util.h | 3
include/libadmin/libadmin.h | 28 ----
include/libdsa/dsalib.h | 2
lib/base/file.cpp | 22 ---
lib/base/nscputil.cpp | 46 +-----
lib/libadmin/util.c | 267 ----------------------------------------
lib/libdsa/dsalib_confs.c | 2
lib/libdsa/dsalib_updown.c | 4
lib/libdsa/dsalib_util.c | 35 -----
mod_restartd/mod_restartd-2.2.c | 4
12 files changed, 29 insertions(+), 401 deletions(-)
New commits:
commit fc8a615d66d526e25356cc0fbeed149ddd64f4a8
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Thu Jan 26 14:24:55 2012 -0700
Ticket #161 - Review and address latest Coverity issues
https://fedorahosted.org/389/ticket/161
Resolves: Ticket #161
Bug Description: Review and address latest Coverity issues
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description:
12456-12455 Time of check time of use
get rid of unused code
12454 Time of check time of use In change_uid()
open file first using open() and perform other operations using the fd
12452 Format string vulnerability
get rid of unused code
12448 Time of check time of use
get rid of unused code
11147-11146 Missing varargs init or cleanup
be sure to call va_end() to cleanup
11145 Resource leak In cgid_server()
close(sd) before leaving function
11144-11142 Resource leak
get rid of unused code
11141 Resource leak In list_directory():
free ar
11140 Resource leak
get rid of unused code
11121 Missing break in switch
get rid of unused code
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/admserv/cgi-src40/config.c b/admserv/cgi-src40/config.c
index fb0188e..74e0a0c 100644
--- a/admserv/cgi-src40/config.c
+++ b/admserv/cgi-src40/config.c
@@ -1020,21 +1020,31 @@ static int change_uid_all(char *dir, int olduid, int newuid) {
static int change_uid(char *fpath, int olduid, int newuid) {
struct stat filestat;
char buf[BIG_LINE];
+ int fd = -1;
+
+ if (0 > (fd = open(fpath, O_RDONLY))) {
+ PR_snprintf(buf, sizeof(buf), "Change Server UID: open(%s) failed,
errno=%d\n", fpath, errno);
+ rpt_err(SYSTEM_ERROR, buf, NULL, NULL);
+ return -1;
+ }
- if (stat(fpath, &filestat) != 0) {
+ if (fstat(fd, &filestat) != 0) {
+ close(fd);
PR_snprintf(buf, sizeof(buf), "Change Server UID: stat(%s) failed,
errno=%d\n", fpath, errno);
rpt_err(SYSTEM_ERROR, buf, NULL, NULL);
return -1;
}
if (filestat.st_uid == olduid) {
- int rc = chown(fpath, newuid, -1);
+ int rc = fchown(fd, newuid, -1);
if (rc != 0) {
+ close(fd);
PR_snprintf(buf, sizeof(buf), "Change Server UID: Can not change file owner
for %s, errno=%d\n", fpath, errno);
rpt_err(SYSTEM_ERROR, buf, NULL, NULL);
return -1;
}
}
+ close(fd);
return 0;
}
#endif
diff --git a/include/base/file.h b/include/base/file.h
index c5baece..9fd0f9e 100644
--- a/include/base/file.h
+++ b/include/base/file.h
@@ -68,8 +68,6 @@ NSAPI_PUBLIC SYS_DIRENT *INTdir_read(SYS_DIR ds);
NSAPI_PUBLIC void INTdir_close(SYS_DIR ds);
#endif /* XP_WIN32 */
-NSAPI_PUBLIC int INTdir_create_all(char *dir);
-
/* --- OBSOLETE ----------------------------------------------------------
* The following macros/functions are obsolete and are only maintained for
* compatibility. Do not use them. 11-19-96
@@ -113,7 +111,6 @@ NSPR_END_EXTERN_C
#define dir_read INTdir_read
#define dir_close INTdir_close
#endif /* XP_WIN32 */
-#define dir_create_all INTdir_create_all
/* Obsolete */
#ifdef XP_WIN32
diff --git a/include/base/util.h b/include/base/util.h
index a9ad091..c77d90c 100644
--- a/include/base/util.h
+++ b/include/base/util.h
@@ -80,8 +80,6 @@ NSAPI_PUBLIC int INTutil_time_equal(struct tm *lms, char *ims);
NSAPI_PUBLIC int INTutil_str_time_equal(char *t1, char *t2);
-NSAPI_PUBLIC int INTutil_uri_is_evil(char *t);
-
NSAPI_PUBLIC void INTutil_uri_parse(char *uri);
NSAPI_PUBLIC void INTutil_uri_unescape(char *s);
@@ -162,7 +160,6 @@ NSPR_END_EXTERN_C
#define util_later_than INTutil_later_than
#define util_time_equal INTutil_time_equal
#define util_str_time_equal INTutil_str_time_equal
-#define util_uri_is_evil INTutil_uri_is_evil
#define util_uri_parse INTutil_uri_parse
#define util_uri_unescape INTutil_uri_unescape
#define util_uri_escape INTutil_uri_escape
diff --git a/include/libadmin/libadmin.h b/include/libadmin/libadmin.h
index 7a47f95..c2e7f5a 100644
--- a/include/libadmin/libadmin.h
+++ b/include/libadmin/libadmin.h
@@ -59,7 +59,6 @@ NSPR_BEGIN_EXTERN_C
#define GET_QUERY_STRING() (getenv("QUERY_STRING"))
#define NOT_ABSOLUTE_PATH(str) (str[0] != '/')
#define CREATE_DIRECTORY(Directory)
-#define FILE_LOCK_PATH (get_flock_path())
#else /* XP_WIN32 */
#define verify_adm_dbm
@@ -106,7 +105,6 @@ NSAPI_PUBLIC char *GetQueryNT(void);
((str[0] != '/') && (str[0] != '\\') && (str[2] !=
'/') && (str[2] != '\\'))
#define CREATE_DIRECTORY(Directory) CreateDirectory(Directory, NULL)
-#define FILE_LOCK_PATH (get_flock_path())
#endif /* XP_WIN32 */
@@ -427,16 +425,6 @@ NSAPI_PUBLIC int all_numbers_float(char *target);
/* util.c */
NSAPI_PUBLIC char *get_serv_url(void);
-/* Run a command and check the output */
-struct runcmd_s {
- char *title;
- char *msg;
- char *arg;
- int sysmsg;
-};
-/* util.c */
-NSAPI_PUBLIC int run_cmd(char *cmd, FILE *closeme, struct runcmd_s *rm);
-
/* This is basically copy_file from the install section, with the error
* reporting changed to match the admin stuff. Since some stuff depends
* on copy_file being the install version, I'll cheat and call this one
@@ -448,28 +436,12 @@ NSAPI_PUBLIC void cp_file(char *sfile, char *dfile, int mode);
/* util.c */
NSAPI_PUBLIC int delete_file(char *path);
-/* Delete the directory with the given path. Returns positive value on failure.*/
-/* BEWARE! Be sure to verify you're not deleting things you */
-/* shouldn't. Testing the directory with "util_uri_is_evil" */
-/* is often a good idea. */
-/* util.c */
-NSAPI_PUBLIC void remove_directory(char *path);
-
/* Simply creates a directory that you give it. Checks for errors and
* all that. (Not to be confused with create_subdirs in install, since
* it relies on some installation stuff.) */
/* util.c */
NSAPI_PUBLIC void create_dir(char *dir, int mode);
-/* Open a file, with file locking. Close a file, releasing the lock. */
-/* util.c */
-NSAPI_PUBLIC FILE *fopen_l(char *pathname, char *mode);
-NSAPI_PUBLIC void fclose_l(FILE *f);
-
-/* helper function to figure out where to put the lock */
-/* util.c */
-NSAPI_PUBLIC char *get_flock_path(void);
-
/* uuencode a given buffer. both src and dst need to be allocated. dst
* should be 1 1/4 as big as src (i saved some math and just made it twice
* as big when I called it) */
diff --git a/include/libdsa/dsalib.h b/include/libdsa/dsalib.h
index c5696c6..a3bf254 100644
--- a/include/libdsa/dsalib.h
+++ b/include/libdsa/dsalib.h
@@ -318,8 +318,6 @@ extern DS_EXPORT_SYMBOL char* ds_become_localuser (char** ds_config);
what they were before calling ds_become_localuser(). */
extern DS_EXPORT_SYMBOL char* ds_become_original();
-extern DS_EXPORT_SYMBOL int ds_search_file(char *filename, char *searchstring, char
**returnstring);
-
/* Display an error to the user and exit from a CGI */
extern DS_EXPORT_SYMBOL void ds_report_error(int type, char *errmsg, char *details);
diff --git a/lib/base/file.cpp b/lib/base/file.cpp
index 850e889..ac2ece6 100644
--- a/lib/base/file.cpp
+++ b/lib/base/file.cpp
@@ -474,28 +474,6 @@ NSAPI_PUBLIC int file_notfound(void)
#endif
}
-NSAPI_PUBLIC int dir_create_all(char *dir)
-{
- struct stat fi;
- char *t;
-
-#ifdef XP_WIN32
- t = dir + 3;
-#else /* XP_UNIX */
- t = dir + 1;
-#endif
- while(1) {
- t = strchr(t, FILE_PATHSEP);
- if(t) *t = '\0';
- if(stat(dir, &fi) == -1) {
- if(dir_create(dir) == -1)
- return -1;
- }
- if(t) *t++ = FILE_PATHSEP;
- else break;
- }
- return 0;
-}
#define ERRMSG_SIZE 35
#include "util.h"
diff --git a/lib/base/nscputil.cpp b/lib/base/nscputil.cpp
index 1267870..77e7a6e 100644
--- a/lib/base/nscputil.cpp
+++ b/lib/base/nscputil.cpp
@@ -537,42 +537,6 @@ NSAPI_PUBLIC int util_str_time_equal(char *t1, char *t2)
}
-/* --------------------------- util_uri_is_evil --------------------------- */
-
-
-NSAPI_PUBLIC int util_uri_is_evil(char *t)
-{
- register int x;
-
- for(x = 0; t[x]; ++x) {
- if(t[x] == '/') {
- if(t[x+1] == '/')
- return 1;
- if(t[x+1] == '.') {
- switch(t[x+2]) {
- case '.':
- if((!t[x+3]) || (t[x+3] == '/'))
- return 1;
- case '/':
- case '\0':
- return 1;
- }
- }
- }
-#ifdef XP_WIN32
- /* On NT, the directory "abc...." is the same as "abc"
- * The only cheap way to catch this globally is to disallow
- * names with the trailing "."s. Hopefully this is not over
- * restrictive
- */
- if ((t[x] == '.') && ( (t[x+1] == '/') || (t[x+1] ==
'\0') )) {
- return 1;
- }
-#endif
- }
- return 0;
-}
-
/* ---------------------------- util_uri_parse ---------------------------- */
NSAPI_PUBLIC void util_uri_parse(char *uri)
@@ -769,9 +733,12 @@ NSAPI_PUBLIC int util_vsnprintf(char *s, int n, register const char
*fmt,
NSAPI_PUBLIC int util_snprintf(char *s, int n, const char *fmt, ...)
{
+ int rc;
va_list args;
va_start(args, fmt);
- return PR_vsnprintf(s, n, fmt, args);
+ rc = PR_vsnprintf(s, n, fmt, args);
+ va_end(args);
+ return rc;
}
NSAPI_PUBLIC int util_vsprintf(char *s, register const char *fmt, va_list args)
@@ -781,9 +748,12 @@ NSAPI_PUBLIC int util_vsprintf(char *s, register const char *fmt,
va_list args)
NSAPI_PUBLIC int util_sprintf(char *s, const char *fmt, ...)
{
+ int rc;
va_list args;
va_start(args, fmt);
- return PR_vsnprintf(s, UTIL_PRF_MAXSIZE, fmt, args);
+ rc = PR_vsnprintf(s, UTIL_PRF_MAXSIZE, fmt, args);
+ va_end(args);
+ return rc;
}
/* ---------------------------- util_sh_escape ---------------------------- */
diff --git a/lib/libadmin/util.c b/lib/libadmin/util.c
index bfb7354..c5689a6 100644
--- a/lib/libadmin/util.c
+++ b/lib/libadmin/util.c
@@ -227,6 +227,7 @@ char **list_directory(char *path, int dashA)
ar = (char **) MALLOC(n * sizeof(char *));
if(!(ds = opendir(path))) {
+ free(ar);
return NULL;
}
@@ -368,161 +369,6 @@ char *get_serv_url(void)
return(getenv("SERVER_URL"));
}
-/* ------------------------------- run_cmd -------------------------------- */
-
-
-/* Previously in install. This is also pretty UNIX-ish. */
-
-/* Nirmal: Added code for Win32 implementation of this function. */
-
-#include <signal.h>
-#ifdef XP_UNIX
-#include <sys/wait.h>
-#endif /* XP_UNIX */
-
-
-int run_cmd(char *cmd, FILE *closeme, struct runcmd_s *rm)
-{
-#ifdef WIN32
- HANDLE hproc;
- PROCESS_INFORMATION child;
- STARTUPINFO siStartInfo ;
-#else
- struct stat fi;
- int exstat;
- char *errmsg, tfn[128];
- FILE *f;
- int fd;
- pid_t pid;
-#endif
-
-
-#ifdef WIN32
- /* Nirmal:
- For now, i will just spawn
- a child in WINNT to execute the command. Communication to
- the parent is done through stdout pipe, that was setup by
- the parent.
-
- */
- hproc = OpenProcess(STANDARD_RIGHTS_REQUIRED, FALSE, GetCurrentProcessId());
- if (hproc == NULL) {
- fprintf(stdout, "Content-type: text/html\n\n");
- fflush(stdout);
- report_error(SYSTEM_ERROR, NULL, "Could not open handle to myself");
- return -1; // stmt. not reached.
- }
-
- ZeroMemory(&child, sizeof(PROCESS_INFORMATION));
- ZeroMemory(&siStartInfo, sizeof(STARTUPINFO));
- siStartInfo.cb = sizeof(STARTUPINFO);
- siStartInfo.lpReserved = siStartInfo.lpReserved2 = NULL;
- siStartInfo.cbReserved2 = 0;
- siStartInfo.lpDesktop = NULL;
- siStartInfo.dwFlags = STARTF_USESHOWWINDOW;
-// Several fields arent used when dwFlags is not set.
-// siStartInfo.hStdInput = hChildStdinRd;
-// siStartInfo.hStdOutput = siStartInfo.hStdError = hChildStdoutWr;
- siStartInfo.wShowWindow = SW_HIDE;
-
- if ( ! CreateProcess(
- NULL, // pointer to name of executable module
- cmd, // pointer to command line string
- NULL, // pointer to process security attribute
- NULL, // pointer to thread security attributes
- TRUE, // handle inheritance flag
- 0, // creation flags
- NULL, // pointer to new environment block
- NULL, // pointer to current directory name
- &siStartInfo, // pointer to STARTUPINFO
- &child // pointer to PROCESS_INFORMATION
- ))
- {
- rm->title = "CreateProcess failed";
- rm->msg = "run_cmd: Can't create new process. ";
- rm->arg = "";
- rm->sysmsg = 1;
- return -1;
- }
- else
- return 0;
-#else
- sprintf(cmd, "%s > /tmp/startmsg.%d 2>&1 < /dev/null", cmd,
getpid()); /* */
- /* FUCK UNIX SIGNALS. */
- signal(SIGCHLD, SIG_DFL);
- switch( (pid = fork()) ) {
- case 0:
- /* Hmm. Work around an apparent bug in stdio. */
- if(closeme)
- close(fileno(closeme));
- execl("/bin/sh", "/bin/sh", "-c", cmd, (char
*)NULL);
- /* DOH! */
- sprintf(tfn, "/tmp/startmsg.%d", getpid());
- if(!(f = fopen(tfn, "w")))
- exit(1);
- fprintf(f, "Exec of %s failed. The error was %s.\n", cmd,
- system_errmsg());
- fclose(f);
- exit(1);
- case -1:
- rm->title = "Fork failed";
- rm->msg = "Can't create new process. %s";
- rm->arg = "";
- rm->sysmsg = 1;
- return -1;
- default:
- sprintf(tfn, "/tmp/startmsg.%d", getpid());
-
- if(waitpid(pid, &exstat, 0) == -1) {
- rm->title = "Can't wait for child";
- rm->msg = "Can't wait for process. %s";
- rm->arg = "";
- rm->sysmsg = 1;
- return -1;
- }
- if(exstat) {
- if((fd = open(tfn, O_RDONLY)) < 0) {
- rm->title = "Can't open error file";
- rm->msg = "Can't find error file %s.";
- rm->arg = cmd;
- rm->sysmsg = 1;
- return -1;
- }
- fstat(fd, &fi);
- if((fi.st_size > 0) && (fi.st_size < 8192)) {
- errmsg = (char *) MALLOC(fi.st_size + 1);
- read(fd, errmsg, fi.st_size);
- errmsg[fi.st_size] = '\0';
- close(fd);
- unlink(tfn);
- rm->title = "Command execution failed";
- rm->msg = "The command did not execute. "
- "Here is the
output:<p>\n<pre>\n%s\n</pre>\n";
- rm->arg = errmsg;
- rm->sysmsg = 0;
- return -1;
- }
- else {
- close(fd);
- unlink(tfn);
-
- rm->title = "Command execution failed";
- rm->msg = "The command didn't execute, and it did not produce
"
- "any output. Run <code>%s</code> from the
command "
- "line and examine the output.\n";
- rm->arg = cmd;
- rm->sysmsg = 0;
- return -1;
- }
- }
- unlink(tfn);
- return 0;
- }
-#endif /* WIN32 */
-
-}
-
-
/* This is basically copy_file from the install section, with the error
* reporting changed to match the admin stuff. Since some stuff depends
@@ -654,65 +500,6 @@ SYS_FILE lf;
HANDLE lf;
#endif
-char *get_flock_path(void)
-{
- char *result="";
- char *port=getenv("SERVER_PORT");
-#ifdef XP_UNIX
- result=(char *) MALLOC(strlen("/tmp/lock.%%s.")+strlen(port)+4);
- sprintf(result, "/tmp/lock.%%s.%s", port);
-#endif
- return result;
-}
-
-/* Open a file with locking, close a file with unlocking. */
-FILE *fopen_l(char *path, char *mode)
-{
- FILE *f = fopen(path, mode);
- char *lockpath;
- char *sn="admin-serv";
- char *flp=FILE_LOCK_PATH;
-
- if(f == NULL) return NULL;
- lockpath=(char *) MALLOC(strlen(sn)+strlen(flp)+16);
- sprintf(lockpath, flp, sn);
-#ifdef XP_UNIX
- if( (lf=system_fopenRW(lockpath)) == SYS_ERROR_FD)
- report_error(FILE_ERROR, lockpath, "Could not open file.");
- if(system_flock(lf)==IO_ERROR)
- report_error(FILE_ERROR, lockpath, "Could not lock file.");
-#elif defined(XP_WIN32)
- /* Using mutexes because if the CGI program dies, the mutex will be
- * automatically released by the OS for another process to grab.
- * Semaphores do not have this property; and if the CGI program crashes,
- * the admin server would be effectively crippled.
- */
- if ( (lf = CreateMutex(NULL, 0, lockpath)) == NULL) {
- report_error(FILE_ERROR, lockpath, "Could not create admin mutex.");
- } else {
- if ( WaitForSingleObject(lf, 60*1000) == WAIT_FAILED) {
- report_error(FILE_ERROR, lockpath, "Unable to obtain mutex after 60
seconds.");
- }
- }
-#endif /* XP_UNIX */
- return f;
-}
-
-void fclose_l(FILE *f)
-{
- fclose(f);
-#ifdef XP_UNIX
- if(system_ulock(lf)==IO_ERROR)
- report_error(FILE_ERROR, NULL, "Could not unlock lock file.");
- system_fclose(lf);
-#elif defined(XP_WIN32)
- if (lf) {
- ReleaseMutex(lf);
- CloseHandle(lf);
- }
-#endif /* XP_UNIX */
-}
-
/* Ripped off from the client. (Sorry, Lou.) */
/* */
/* The magic set of 64 chars in the uuencoded data */
@@ -833,58 +620,6 @@ char *alert_word_wrap(char *str, int width, char *linefeed)
return ans;
}
-void remove_directory(char *path)
-{
- struct stat finfo;
- char **dirlisting;
- register int x=0;
- int stat_good = 0;
- char *fullpath = NULL;
-
-#ifdef XP_UNIX
- stat_good = (lstat(path, &finfo) == -1 ? 0 : 1);
-#else /* WIN32 */
- stat_good = (stat(path, &finfo) == -1 ? 0 : 1);
-#endif /* XP_UNIX */
-
- if(!stat_good) return;
-
- if(S_ISDIR(finfo.st_mode)) {
- dirlisting = list_directory(path,1);
- if(!dirlisting) return;
-
- for(x=0; dirlisting[x]; x++) {
- fullpath = (char *) MALLOC(strlen(path) +
- strlen(dirlisting[x]) + 4);
- sprintf(fullpath, "%s%c%s", path, FILE_PATHSEP, dirlisting[x]);
-#ifdef XP_UNIX
- stat_good = (lstat(fullpath, &finfo) == -1 ? 0 : 1);
-#else /* WIN32 */
- stat_good = (stat(fullpath, &finfo) == -1 ? 0 : 1);
-#endif /* XP_UNIX */
- if(!stat_good) continue;
- if(S_ISDIR(finfo.st_mode)) {
- remove_directory(fullpath);
- } else {
- fprintf(stdout, "<i>Removing file</i> "
- "<code>%s</code><br>\n",
fullpath);
- unlink(fullpath);
- }
- FREE(fullpath);
- }
- fprintf(stdout, "<i>Removing directory</i> "
- "<code>%s</code><br>\n", path);
-#ifdef XP_UNIX
- rmdir(path);
-#else /* XP_WIN32 */
- RemoveDirectory(path);
-#endif /* XP_WIN32 */
- } else {
- fprintf(stdout, "<i>Removing file</i>
<code>%s</code><br>\n", path);
- unlink(path);
- }
- return;
-}
/* do fgets with a filebuffer *, instead of a File *. Can't use util_getline
because it complains if the line is too long.
diff --git a/lib/libdsa/dsalib_confs.c b/lib/libdsa/dsalib_confs.c
index 3c24c98..36d9356 100644
--- a/lib/libdsa/dsalib_confs.c
+++ b/lib/libdsa/dsalib_confs.c
@@ -145,7 +145,7 @@ ds_parm_in_line(char *confline, char *parm)
if ( parm == NULL )
return(0);
parm_size = strlen(parm);
- if ( parm_size == (int)NULL )
+ if ( parm_size == 0 )
return(0);
if ( PL_strncasecmp(confline, parm, parm_size) == 0 )
if ( ((int) strlen(confline)) > parm_size )
diff --git a/lib/libdsa/dsalib_updown.c b/lib/libdsa/dsalib_updown.c
index b9d8f28..0bef3ab 100644
--- a/lib/libdsa/dsalib_updown.c
+++ b/lib/libdsa/dsalib_updown.c
@@ -302,9 +302,11 @@ ds_bring_down_server()
int status;
int cur_size;
char *errorlog;
+#if defined( WITH_SYSTEMD ) || defined( ENABLE_SERVICE )
char stop_cmd[BIG_LINE];
int error;
-
+#endif
+
status = ds_get_updown_status(); /* set server_pid too! */
if ( status != DS_SERVER_UP ) {
ds_send_error("The server is not up.", 0);
diff --git a/lib/libdsa/dsalib_util.c b/lib/libdsa/dsalib_util.c
index a03c827..da875df 100644
--- a/lib/libdsa/dsalib_util.c
+++ b/lib/libdsa/dsalib_util.c
@@ -287,41 +287,6 @@ ds_become_original (char **ds_config)
#endif
}
-/* returns 1 if string "searchstring" found in file "filename" */
-/* if found, returnstring is allocated and filled with the line */
-/* caller should release the memory */
-DS_EXPORT_SYMBOL int
-ds_search_file(char *filename, char *searchstring, char **returnstring)
-{
- struct stat finfo;
- FILE * sf;
- char big_line[BIG_LINE];
-
- if( filename == NULL )
- return 0;
-
- if( stat(filename, &finfo) != 0 ) /* successful */
- return 0;
-
- if( !(sf = fopen(filename, "r")) )
- return 0;
-
- while ( fgets(big_line, BIG_LINE, sf) ) {
- if( strstr( big_line, searchstring ) != NULL ) {
- *returnstring = (char *)malloc(strlen(big_line) + 1);
- if (NULL != *returnstring) {
- strcpy(*returnstring, big_line);
- }
- fclose(sf);
- return 1;
- }
- }
-
- fclose(sf);
-
- return 0;
-}
-
/*
* on linux when running as root, doing something like
* system("date > out.log 2>&1") will fail, because of an
diff --git a/mod_restartd/mod_restartd-2.2.c b/mod_restartd/mod_restartd-2.2.c
index a4e73fb..4da4b84 100644
--- a/mod_restartd/mod_restartd-2.2.c
+++ b/mod_restartd/mod_restartd-2.2.c
@@ -645,12 +645,14 @@ static int cgid_server(void *data)
ap_log_error(APLOG_MARK, APLOG_ERR, errno, main_server,
"Couldn't bind unix domain socket %s",
sockname);
+ close(sd);
return errno;
}
if (listen(sd, DEFAULT_CGID_LISTENBACKLOG) < 0) {
ap_log_error(APLOG_MARK, APLOG_ERR, errno, main_server,
"Couldn't listen on unix domain socket");
+ close(sd);
return errno;
}
@@ -659,6 +661,7 @@ static int cgid_server(void *data)
ap_log_error(APLOG_MARK, APLOG_ERR, errno, main_server,
"Couldn't change owner of unix domain socket %s",
sockname);
+ close(sd);
return errno;
}
}
@@ -836,6 +839,7 @@ static int cgid_server(void *data)
}
}
}
+ close(sd);
return -1;
}