Fix memory leak in nonrootconf patch and merge it with file_stat patch.

This commit is contained in:
Martin Nagy 2008-07-01 13:46:33 +00:00
parent 8edf05f270
commit bc3bc4dbe8
3 changed files with 47 additions and 49 deletions

View File

@ -1,6 +1,46 @@
--- vsftpd-2.0.1/twoprocess.c.nonrootconf 2004-07-02 18:47:51.000000000 +0200
+++ vsftpd-2.0.1/twoprocess.c 2005-02-08 09:37:26.641905544 +0100
@@ -416,11 +416,17 @@
diff -up vsftpd-2.0.6/parseconf.c.nonrootconf vsftpd-2.0.6/parseconf.c
--- vsftpd-2.0.6/parseconf.c.nonrootconf 2008-02-12 05:53:32.000000000 +0100
+++ vsftpd-2.0.6/parseconf.c 2008-07-01 12:28:12.000000000 +0200
@@ -15,6 +15,7 @@
#include "defs.h"
#include "sysutil.h"
#include "utility.h"
+#include "sysstr.h"
static const char* s_p_saved_filename;
static int s_strings_copied;
@@ -182,6 +183,8 @@ vsf_parseconf_load_file(const char* p_fi
struct mystr config_file_str = INIT_MYSTR;
struct mystr config_setting_str = INIT_MYSTR;
struct mystr config_value_str = INIT_MYSTR;
+ struct vsf_sysutil_statbuf* p_statbuf = 0;
+
unsigned int str_pos = 0;
int retval;
if (!p_filename)
@@ -210,7 +213,9 @@ vsf_parseconf_load_file(const char* p_fi
copy_string_settings();
}
retval = str_fileread(&config_file_str, p_filename, VSFTP_CONF_FILE_MAX);
- if (vsf_sysutil_retval_is_error(retval))
+ (int)vsf_sysutil_stat(p_filename, &p_statbuf);
+ /* Security - die unless the conf file is owned by root */
+ if (vsf_sysutil_retval_is_error(retval) || vsf_sysutil_statbuf_get_uid(p_statbuf) != VSFTP_ROOT_UID)
{
if (errs_fatal)
{
@@ -221,6 +226,7 @@ vsf_parseconf_load_file(const char* p_fi
return;
}
}
+ vsf_sysutil_free(p_statbuf);
while (str_getline(&config_file_str, &config_setting_str, &str_pos))
{
if (str_isempty(&config_setting_str) ||
diff -up vsftpd-2.0.6/twoprocess.c.nonrootconf vsftpd-2.0.6/twoprocess.c
--- vsftpd-2.0.6/twoprocess.c.nonrootconf 2008-02-12 04:18:34.000000000 +0100
+++ vsftpd-2.0.6/twoprocess.c 2008-07-01 12:21:28.000000000 +0200
@@ -423,11 +423,17 @@ handle_per_user_config(const struct myst
str_append_char(&filename_str, '/');
str_append_str(&filename_str, p_user_str);
retval = str_stat(&filename_str, &p_statbuf);
@ -22,39 +62,10 @@
}
str_free(&filename_str);
vsf_sysutil_free(p_statbuf);
--- vsftpd-2.0.1/parseconf.c.nonrootconf 2004-07-02 13:23:56.000000000 +0200
+++ vsftpd-2.0.1/parseconf.c 2005-02-08 09:37:26.642905392 +0100
@@ -15,6 +15,7 @@
#include "defs.h"
#include "sysutil.h"
#include "utility.h"
+#include "sysstr.h"
static const char* s_p_saved_filename;
static int s_strings_copied;
@@ -167,6 +168,8 @@
struct mystr config_file_str = INIT_MYSTR;
struct mystr config_setting_str = INIT_MYSTR;
struct mystr config_value_str = INIT_MYSTR;
+ struct vsf_sysutil_statbuf* p_statbuf = 0;
+
unsigned int str_pos = 0;
int retval;
if (!p_filename)
@@ -195,7 +198,9 @@
copy_string_settings();
}
retval = str_fileread(&config_file_str, p_filename, VSFTP_CONF_FILE_MAX);
- if (vsf_sysutil_retval_is_error(retval))
+ (int)str_stat(&config_file_str, &p_statbuf);
+ /* Security - die unless the conf file is owned by root */
+ if (vsf_sysutil_retval_is_error(retval) || vsf_sysutil_statbuf_get_uid(p_statbuf) != VSFTP_ROOT_UID)
{
if (errs_fatal)
{
--- vsftpd-2.0.1/vsftpd.8.nonrootconf 2005-02-08 09:37:26.000000000 +0100
+++ vsftpd-2.0.1/vsftpd.8 2005-02-08 09:44:21.173887104 +0100
@@ -28,7 +28,8 @@
diff -up vsftpd-2.0.6/vsftpd.8.nonrootconf vsftpd-2.0.6/vsftpd.8
--- vsftpd-2.0.6/vsftpd.8.nonrootconf 2008-07-01 12:21:28.000000000 +0200
+++ vsftpd-2.0.6/vsftpd.8 2008-07-01 12:21:28.000000000 +0200
@@ -28,7 +28,8 @@ binary will then launch the FTP service
.Sh OPTIONS
An optional
.Op configuration file

View File

@ -1,11 +0,0 @@
--- vsftpd-2.0.5/parseconf.c.old 2006-12-05 12:19:48.000000000 +0100
+++ vsftpd-2.0.5/parseconf.c 2006-12-05 12:19:54.000000000 +0100
@@ -208,7 +208,7 @@
copy_string_settings();
}
retval = str_fileread(&config_file_str, p_filename, VSFTP_CONF_FILE_MAX);
- (int)str_stat(&config_file_str, &p_statbuf);
+ (int)vsf_sysutil_stat(p_filename, &p_statbuf);
/* Security - die unless the conf file is owned by root */
if (vsf_sysutil_retval_is_error(retval) || vsf_sysutil_statbuf_get_uid(p_statbuf) != VSFTP_ROOT_UID)
{

View File

@ -33,7 +33,6 @@ Patch20: vsftpd-2.0.5-add_ipv6_option.patch
Patch21: vsftpd-2.0.5-correct_comments.patch
Patch22: vsftpd-2.0.5-man.patch
Patch23: vsftpd-2.0.4-filter.patch
Patch24: vsftpd-2.0.5-file_stat.patch
Patch26: vsftpd-2.0.5-bind_denied.patch
Patch29: vsftpd-2.0.5-pasv_dot.patch
Patch30: vsftpd-2.0.5-pam_end.patch
@ -91,7 +90,6 @@ cp %{SOURCE1} .
%patch21 -p1 -b .comments
%patch22 -p1 -b .manp
%patch23 -p1 -b .filter
%patch24 -p1 -b .file_stat
%patch26 -p1 -b .bind_denied
%patch29 -p1 -b .pasv_dot
%patch30 -p1 -b .pam_end