From bc3bc4dbe8b09389f88ed8b6f85a093ba3b4887d Mon Sep 17 00:00:00 2001 From: Martin Nagy Date: Jul 01 2008 13:46:33 +0000 Subject: Fix memory leak in nonrootconf patch and merge it with file_stat patch. --- diff --git a/vsftpd-1.2.1-nonrootconf.patch b/vsftpd-1.2.1-nonrootconf.patch index 5496d21..4eaf381 100644 --- a/vsftpd-1.2.1-nonrootconf.patch +++ b/vsftpd-1.2.1-nonrootconf.patch @@ -1,29 +1,6 @@ ---- 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 @@ - str_append_char(&filename_str, '/'); - str_append_str(&filename_str, p_user_str); - retval = str_stat(&filename_str, &p_statbuf); -- /* Security - ignore unless owned by root */ -- if (!vsf_sysutil_retval_is_error(retval) && -- vsf_sysutil_statbuf_get_uid(p_statbuf) == VSFTP_ROOT_UID) -+ /* Security - die unless owned by root */ -+ if (!vsf_sysutil_retval_is_error(retval)) - { -- vsf_parseconf_load_file(str_getbuf(&filename_str), 1); -+ if (vsf_sysutil_statbuf_get_uid(p_statbuf) == VSFTP_ROOT_UID) -+ { -+ vsf_parseconf_load_file(str_getbuf(&filename_str), 1); -+ } -+ else -+ { -+ die("reading non-root config file"); -+ } - } - 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 +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" @@ -32,7 +9,7 @@ static const char* s_p_saved_filename; static int s_strings_copied; -@@ -167,6 +168,8 @@ +@@ -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; @@ -41,20 +18,54 @@ unsigned int str_pos = 0; int retval; if (!p_filename) -@@ -195,7 +198,9 @@ +@@ -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)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) { 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 @@ +@@ -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); +- /* Security - ignore unless owned by root */ +- if (!vsf_sysutil_retval_is_error(retval) && +- vsf_sysutil_statbuf_get_uid(p_statbuf) == VSFTP_ROOT_UID) ++ /* Security - die unless owned by root */ ++ if (!vsf_sysutil_retval_is_error(retval)) + { +- vsf_parseconf_load_file(str_getbuf(&filename_str), 1); ++ if (vsf_sysutil_statbuf_get_uid(p_statbuf) == VSFTP_ROOT_UID) ++ { ++ vsf_parseconf_load_file(str_getbuf(&filename_str), 1); ++ } ++ else ++ { ++ die("reading non-root config file"); ++ } + } + str_free(&filename_str); + vsf_sysutil_free(p_statbuf); +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 diff --git a/vsftpd-2.0.5-file_stat.patch b/vsftpd-2.0.5-file_stat.patch deleted file mode 100644 index 1e81a3c..0000000 --- a/vsftpd-2.0.5-file_stat.patch +++ /dev/null @@ -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) - { diff --git a/vsftpd.spec b/vsftpd.spec index 4b42f26..61b04f5 100644 --- a/vsftpd.spec +++ b/vsftpd.spec @@ -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