vsftpd/vsftpd-2.1.0-trim.patch
Jiri Skala 9310f56259 - updated to latest upstream version
- improved daemonizing - init script gets correct return code if binding
    fails
- trim white spaces from option values
- fixed #483604 - vsftpd not honouring delay_failed_login when userlist
    active
2009-05-04 14:09:08 +00:00

79 lines
3.0 KiB
Diff

diff -up vsftpd-2.1.0/parseconf.c.trim vsftpd-2.1.0/parseconf.c
--- vsftpd-2.1.0/parseconf.c.trim 2009-03-24 15:50:47.000000000 +0100
+++ vsftpd-2.1.0/parseconf.c 2009-03-24 15:51:10.000000000 +0100
@@ -273,7 +273,7 @@ handle_config_setting(struct mystr* p_se
}
else
{
- *p_curr_setting = str_strdup(p_value_str);
+ *p_curr_setting = str_strdup_trimmed(p_value_str);
}
return;
}
diff -up vsftpd-2.1.0/str.c.trim vsftpd-2.1.0/str.c
--- vsftpd-2.1.0/str.c.trim 2009-03-24 15:50:34.000000000 +0100
+++ vsftpd-2.1.0/str.c 2009-03-24 15:54:07.000000000 +0100
@@ -89,6 +89,18 @@ str_strdup(const struct mystr* p_str)
return vsf_sysutil_strdup(str_getbuf(p_str));
}
+const char*
+str_strdup_trimmed(const struct mystr* p_str)
+{
+ const char* p_trimmed = str_getbuf(p_str);
+ int h, t, newlen;
+
+ for (h = 0; h < (int)str_getlen(p_str) && vsf_sysutil_isspace(p_trimmed[h]); h++) ;
+ for (t = str_getlen(p_str) - 1; t >= 0 && vsf_sysutil_isspace(p_trimmed[t]); t--) ;
+ newlen = t - h + 1;
+ return newlen ? vsf_sysutil_strndup(p_trimmed+h, (unsigned int)newlen) : 0L;
+}
+
void
str_alloc_alt_term(struct mystr* p_str, const char* p_src, char term)
{
diff -up vsftpd-2.1.0/str.h.trim vsftpd-2.1.0/str.h
--- vsftpd-2.1.0/str.h.trim 2009-03-24 15:50:31.000000000 +0100
+++ vsftpd-2.1.0/str.h 2009-03-24 15:51:48.000000000 +0100
@@ -31,6 +31,7 @@ void str_alloc_ulong(struct mystr* p_str
void str_alloc_filesize_t(struct mystr* p_str, filesize_t the_filesize);
void str_copy(struct mystr* p_dest, const struct mystr* p_src);
const char* str_strdup(const struct mystr* p_str);
+const char* str_strdup_trimmed(const struct mystr* p_str);
void str_empty(struct mystr* p_str);
void str_free(struct mystr* p_str);
void str_trunc(struct mystr* p_str, unsigned int trunc_len);
diff -up vsftpd-2.1.0/sysutil.c.trim vsftpd-2.1.0/sysutil.c
--- vsftpd-2.1.0/sysutil.c.trim 2009-03-24 15:50:19.000000000 +0100
+++ vsftpd-2.1.0/sysutil.c 2009-03-24 15:52:53.000000000 +0100
@@ -1031,6 +1031,18 @@ vsf_sysutil_strdup(const char* p_str)
return strdup(p_str);
}
+char*
+vsf_sysutil_strndup(const char* p_str, unsigned int p_len)
+{
+ char *new = (char *)malloc(p_len+1);
+
+ if (new == NULL)
+ return NULL;
+
+ new[p_len]='\0';
+ return (char *)memcpy(new, p_str, p_len);
+}
+
void
vsf_sysutil_memclr(void* p_dest, unsigned int size)
{
diff -up vsftpd-2.1.0/sysutil.h.trim vsftpd-2.1.0/sysutil.h
--- vsftpd-2.1.0/sysutil.h.trim 2009-03-24 15:50:23.000000000 +0100
+++ vsftpd-2.1.0/sysutil.h 2009-03-24 15:52:14.000000000 +0100
@@ -184,6 +184,7 @@ int vsf_sysutil_wait_get_exitcode(
/* Various string functions */
unsigned int vsf_sysutil_strlen(const char* p_text);
char* vsf_sysutil_strdup(const char* p_str);
+char* vsf_sysutil_strndup(const char* p_str, unsigned int p_len);
void vsf_sysutil_memclr(void* p_dest, unsigned int size);
void vsf_sysutil_memcpy(void* p_dest, const void* p_src,
const unsigned int size);