1 Author: Jiri Skala <jskala@redhat.com>
2 Description: trim white spaces from option values (Closes: #419857, #536803).
4 diff -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
11 - *p_curr_setting = str_strdup(&s_value_str);
12 + *p_curr_setting = str_strdup_trimmed(&s_value_str);
16 diff -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));
24 +str_strdup_trimmed(const struct mystr* p_str)
26 + const char* p_trimmed = str_getbuf(p_str);
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--) ;
32 + return newlen ? vsf_sysutil_strndup(p_trimmed+h, (unsigned int)newlen) : 0L;
36 str_alloc_alt_term(struct mystr* p_str, const char* p_src, char term)
38 diff -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);
49 diff -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)
57 +vsf_sysutil_strndup(const char* p_str, unsigned int p_len)
59 + char *new = (char *)malloc(p_len+1);
65 + return (char *)memcpy(new, p_str, p_len);
69 vsf_sysutil_memclr(void* p_dest, unsigned int size)
71 diff -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);