Blame SOURCES/vsftpd-2.1.0-trim.patch

bd78b8
diff -up vsftpd-2.2.0/parseconf.c.trim vsftpd-2.2.0/parseconf.c
bd78b8
--- vsftpd-2.2.0/parseconf.c.trim	2009-08-04 08:01:10.000000000 +0200
bd78b8
+++ vsftpd-2.2.0/parseconf.c	2009-08-04 08:10:49.000000000 +0200
bd78b8
@@ -275,7 +275,7 @@ vsf_parseconf_load_setting(const char* p
bd78b8
         }
bd78b8
         else
bd78b8
         {
bd78b8
-          *p_curr_setting = str_strdup(&s_value_str);
bd78b8
+          *p_curr_setting = str_strdup_trimmed(&s_value_str);
bd78b8
         }
bd78b8
         return;
bd78b8
       }
bd78b8
diff -up vsftpd-2.2.0/str.c.trim vsftpd-2.2.0/str.c
bd78b8
--- vsftpd-2.2.0/str.c.trim	2009-08-04 08:01:10.000000000 +0200
bd78b8
+++ vsftpd-2.2.0/str.c	2009-08-04 08:01:10.000000000 +0200
bd78b8
@@ -89,6 +89,18 @@ str_strdup(const struct mystr* p_str)
bd78b8
   return vsf_sysutil_strdup(str_getbuf(p_str));
bd78b8
 }
bd78b8
 
bd78b8
+const char*
bd78b8
+str_strdup_trimmed(const struct mystr* p_str)
bd78b8
+{
bd78b8
+  const char* p_trimmed = str_getbuf(p_str);
bd78b8
+  int h, t, newlen;
bd78b8
+
bd78b8
+  for (h = 0; h < (int)str_getlen(p_str) && vsf_sysutil_isspace(p_trimmed[h]); h++) ;
bd78b8
+  for (t = str_getlen(p_str) - 1; t >= 0 && vsf_sysutil_isspace(p_trimmed[t]); t--) ;
bd78b8
+  newlen = t - h + 1;
bd78b8
+  return newlen ? vsf_sysutil_strndup(p_trimmed+h, (unsigned int)newlen) : 0L;
bd78b8
+}
bd78b8
+
bd78b8
 void
bd78b8
 str_alloc_alt_term(struct mystr* p_str, const char* p_src, char term)
bd78b8
 {
bd78b8
diff -up vsftpd-2.2.0/str.h.trim vsftpd-2.2.0/str.h
bd78b8
--- vsftpd-2.2.0/str.h.trim	2009-08-04 08:01:10.000000000 +0200
bd78b8
+++ vsftpd-2.2.0/str.h	2009-08-04 08:01:10.000000000 +0200
bd78b8
@@ -31,6 +31,7 @@ void str_alloc_ulong(struct mystr* p_str
bd78b8
 void str_alloc_filesize_t(struct mystr* p_str, filesize_t the_filesize);
bd78b8
 void str_copy(struct mystr* p_dest, const struct mystr* p_src);
bd78b8
 const char* str_strdup(const struct mystr* p_str);
bd78b8
+const char* str_strdup_trimmed(const struct mystr* p_str);
bd78b8
 void str_empty(struct mystr* p_str);
bd78b8
 void str_free(struct mystr* p_str);
bd78b8
 void str_trunc(struct mystr* p_str, unsigned int trunc_len);
bd78b8
diff -up vsftpd-2.2.0/sysutil.c.trim vsftpd-2.2.0/sysutil.c
bd78b8
--- vsftpd-2.2.0/sysutil.c.trim	2009-07-16 05:32:21.000000000 +0200
bd78b8
+++ vsftpd-2.2.0/sysutil.c	2009-08-04 08:01:10.000000000 +0200
bd78b8
@@ -1032,6 +1032,18 @@ vsf_sysutil_strdup(const char* p_str)
bd78b8
   return strdup(p_str);
bd78b8
 }
bd78b8
 
bd78b8
+char*
bd78b8
+vsf_sysutil_strndup(const char* p_str, unsigned int p_len)
bd78b8
+{
bd78b8
+  char *new = (char *)malloc(p_len+1);
bd78b8
+
bd78b8
+  if (new == NULL)
bd78b8
+    return NULL;
bd78b8
+
bd78b8
+  new[p_len]='\0';
bd78b8
+  return (char *)memcpy(new, p_str, p_len);
bd78b8
+}
bd78b8
+
bd78b8
 void
bd78b8
 vsf_sysutil_memclr(void* p_dest, unsigned int size)
bd78b8
 {
bd78b8
diff -up vsftpd-2.2.0/sysutil.h.trim vsftpd-2.2.0/sysutil.h
bd78b8
--- vsftpd-2.2.0/sysutil.h.trim	2009-07-16 05:31:53.000000000 +0200
bd78b8
+++ vsftpd-2.2.0/sysutil.h	2009-08-04 08:01:10.000000000 +0200
bd78b8
@@ -186,6 +186,7 @@ int vsf_sysutil_wait_get_exitcode(
bd78b8
 /* Various string functions */
bd78b8
 unsigned int vsf_sysutil_strlen(const char* p_text);
bd78b8
 char* vsf_sysutil_strdup(const char* p_str);
bd78b8
+char* vsf_sysutil_strndup(const char* p_str, unsigned int p_len);
bd78b8
 void vsf_sysutil_memclr(void* p_dest, unsigned int size);
bd78b8
 void vsf_sysutil_memcpy(void* p_dest, const void* p_src,
bd78b8
                         const unsigned int size);