summaryrefslogtreecommitdiffstats
path: root/vsftpd/05-whitespaces.patch
diff options
context:
space:
mode:
Diffstat (limited to 'vsftpd/05-whitespaces.patch')
-rw-r--r--vsftpd/05-whitespaces.patch81
1 files changed, 81 insertions, 0 deletions
diff --git a/vsftpd/05-whitespaces.patch b/vsftpd/05-whitespaces.patch
new file mode 100644
index 0000000000..569ce38ed4
--- /dev/null
+++ b/vsftpd/05-whitespaces.patch
@@ -0,0 +1,81 @@
1Author: Jiri Skala <jskala@redhat.com>
2Description: trim white spaces from option values (Closes: #419857, #536803).
3
4diff -Naurp vsftpd.orig/parseconf.c vsftpd/parseconf.c
5--- vsftpd.orig/parseconf.c 2009-10-02 14:15:18.000000000 +0200
6+++ vsftpd/parseconf.c 2009-10-18 11:28:31.000000000 +0200
7@@ -275,7 +275,7 @@ vsf_parseconf_load_setting(const char* p
8 }
9 else
10 {
11- *p_curr_setting = str_strdup(&s_value_str);
12+ *p_curr_setting = str_strdup_trimmed(&s_value_str);
13 }
14 return;
15 }
16diff -Naurp vsftpd.orig/str.c vsftpd/str.c
17--- vsftpd.orig/str.c 2009-10-02 14:15:18.000000000 +0200
18+++ vsftpd/str.c 2009-10-18 11:28:31.000000000 +0200
19@@ -89,6 +89,18 @@ str_strdup(const struct mystr* p_str)
20 return vsf_sysutil_strdup(str_getbuf(p_str));
21 }
22
23+const char*
24+str_strdup_trimmed(const struct mystr* p_str)
25+{
26+ const char* p_trimmed = str_getbuf(p_str);
27+ int h, t, newlen;
28+
29+ for (h = 0; h < (int)str_getlen(p_str) && vsf_sysutil_isspace(p_trimmed[h]); h++) ;
30+ for (t = str_getlen(p_str) - 1; t >= 0 && vsf_sysutil_isspace(p_trimmed[t]); t--) ;
31+ newlen = t - h + 1;
32+ return newlen ? vsf_sysutil_strndup(p_trimmed+h, (unsigned int)newlen) : 0L;
33+}
34+
35 void
36 str_alloc_alt_term(struct mystr* p_str, const char* p_src, char term)
37 {
38diff -Naurp vsftpd.orig/str.h vsftpd/str.h
39--- vsftpd.orig/str.h 2009-10-02 14:15:18.000000000 +0200
40+++ vsftpd/str.h 2009-10-18 11:28:31.000000000 +0200
41@@ -31,6 +31,7 @@ void str_alloc_ulong(struct mystr* p_str
42 void str_alloc_filesize_t(struct mystr* p_str, filesize_t the_filesize);
43 void str_copy(struct mystr* p_dest, const struct mystr* p_src);
44 const char* str_strdup(const struct mystr* p_str);
45+const char* str_strdup_trimmed(const struct mystr* p_str);
46 void str_empty(struct mystr* p_str);
47 void str_free(struct mystr* p_str);
48 void str_trunc(struct mystr* p_str, unsigned int trunc_len);
49diff -Naurp vsftpd.orig/sysutil.c vsftpd/sysutil.c
50--- vsftpd.orig/sysutil.c 2009-10-02 14:15:18.000000000 +0200
51+++ vsftpd/sysutil.c 2009-10-18 11:28:31.000000000 +0200
52@@ -1033,6 +1033,18 @@ vsf_sysutil_strdup(const char* p_str)
53 return strdup(p_str);
54 }
55
56+char*
57+vsf_sysutil_strndup(const char* p_str, unsigned int p_len)
58+{
59+ char *new = (char *)malloc(p_len+1);
60+
61+ if (new == NULL)
62+ return NULL;
63+
64+ new[p_len]='\0';
65+ return (char *)memcpy(new, p_str, p_len);
66+}
67+
68 void
69 vsf_sysutil_memclr(void* p_dest, unsigned int size)
70 {
71diff -Naurp vsftpd.orig/sysutil.h vsftpd/sysutil.h
72--- vsftpd.orig/sysutil.h 2009-10-02 14:15:18.000000000 +0200
73+++ vsftpd/sysutil.h 2009-10-18 11:28:31.000000000 +0200
74@@ -186,6 +186,7 @@ int vsf_sysutil_wait_get_exitcode(
75 /* Various string functions */
76 unsigned int vsf_sysutil_strlen(const char* p_text);
77 char* vsf_sysutil_strdup(const char* p_str);
78+char* vsf_sysutil_strndup(const char* p_str, unsigned int p_len);
79 void vsf_sysutil_memclr(void* p_dest, unsigned int size);
80 void vsf_sysutil_memcpy(void* p_dest, const void* p_src,
81 const unsigned int size);