forked from pool/vsftpd
cf83fc9250
* Make listen mode the default. * Fix missing "const" in ssl.c * Add seccompsandbox.c to support a seccomp filter sandbox; works against Ubuntu 12.04 ABI. * Rearrange ftppolicy.c a bit so the syscall list is easily comparable with seccompsandbox.c * Rename deprecated "sandbox" to "ptrace_sandbox". * Add a few more state checks to the privileged helper processes. * Add tunable "seccomp_sandbox", default on. * Use hardened build flags. * Retry creating a PASV socket upon port reuse race between bind() and listen(), patch from Ralph Wuerthner <ralph.wuerthner@de.ibm.com>. * Don't die() if recv() indicates a closed remote connection. Problem report on a Windows client from Herbert van den Bergh, <herbert.van.den.bergh@oracle.com>. * Add new config setting "allow_writeable_chroot" to help people in a bit of a spot with the v2.3.5 defensive change. Only applies to non-anonymous. * Remove a couple of fixed things from BUGS. * strlen() trunction fix -- no particular impact. * Apply some tidyups from mmoufid@yorku.ca. * Fix delete_failed_uploads if there is a timeout. Report from Alejandro Hernández Hdez <aalejandrohdez@gmail.com>. * Fix other data channel bugs such as failure to log failure upon timeout. * Use exit codes a bit more consistently. * Fix bad interaction between SSL and trans_chunk_size. * Redo data timeout to fire properly for SSL sessions. * Redo idle timeout to fire properly for SSL sessions. * Make sure PROT_EXEC isn't allowed, thanks to Will Drewry for noticing. * Use 10 minutes as a max linger time just in case an alarm gets lost. * Change PR_SET_NO_NEW_PRIVS define, from Kees Cook. * Add AES128-SHA to default SSL cipher suites for FileZilla compatibility. Unfortunately the default vsftpd SSL confiuration still doesn't fully work with FileZilla, because FileZilla has a data connection security problem: no client certificate presentation and no session reuse. At least the error message is now very clear. * Add restart_syscall to seccomp policy. Triggers reliably if you strace whilst a data transfer is in progress. * Fix delete_failed_uploads for anonymous sessions. * Don't listen for urgent data if the control connection is SSL, due to possible protocol synchronization issues. - SUSE specific changes: * turn off the listen mode (listen=NO) by default and change README.SUSE * merge new hardended flags for build and linking * fix the wrong Type=forking from systemd service file * turn off the seccomp_sandbox off by default as SUSE kernel does not support it (yet) OBS-URL: https://build.opensuse.org/package/show/network/vsftpd?expand=0&rev=38
106 lines
2.8 KiB
Diff
106 lines
2.8 KiB
Diff
Index: str.c
|
|
===================================================================
|
|
--- str.c.orig 2012-03-28 17:25:40.000000000 +0200
|
|
+++ str.c 2012-04-10 16:10:59.965767345 +0200
|
|
@@ -27,6 +27,24 @@
|
|
const char* p_buf2, unsigned int buf2_len);
|
|
|
|
/* Private functions */
|
|
+static int
|
|
+continuation_char(unsigned char str, int* val)
|
|
+{
|
|
+ if ((str & 0xc0) != 0x80) /* 10xxxxxx */
|
|
+ return 0;
|
|
+ (*val) <<= 6;
|
|
+ (*val) |= str & 0x3f;
|
|
+ return 1;
|
|
+}
|
|
+
|
|
+static int
|
|
+unicode_valid(int b)
|
|
+{
|
|
+ return (b < 0x110000 && ((b & 0xFFFFF800) != 0xD800)
|
|
+ && (b < 0xFDD0 || b > 0xFDEF)
|
|
+ && (b & 0xFFFE) != 0xFFFE);
|
|
+}
|
|
+
|
|
static void
|
|
s_setbuf(struct mystr* p_str, char* p_newbuf)
|
|
{
|
|
@@ -181,6 +199,45 @@
|
|
p_str->p_buf[res_len - 1] = '\0';
|
|
}
|
|
|
|
+int str_is_utf8( const struct mystr* p_str )
|
|
+{
|
|
+ unsigned int i;
|
|
+ int min = 0, val = 0;
|
|
+
|
|
+ for(i = 0; i < p_str->len; i++)
|
|
+ {
|
|
+ if( (unsigned char)p_str->p_buf[i] < 128) continue;
|
|
+
|
|
+ if((p_str->p_buf[i] & 0xe0) == 0xc0) { /* 110xxxxx */
|
|
+ if((p_str->p_buf[i] & 0x1e) == 0) return 0;
|
|
+ i++;
|
|
+ if((p_str->p_buf[i] & 0xc0) != 0x80) /* 10xxxxxx */
|
|
+ return 0;
|
|
+ } else {
|
|
+ if((p_str->p_buf[i] & 0xf0) == 0xe0) { /* 1110xxxx */
|
|
+ min = (1 << 11);
|
|
+ val = p_str->p_buf[i] & 0x0f;
|
|
+ goto TWO_REMAINING;
|
|
+ } else if((p_str->p_buf[i] & 0xf8) == 0xf0) { /* 11110xxx */
|
|
+ min = (1 << 16);
|
|
+ val = p_str->p_buf[i] & 0x07;
|
|
+ } else {
|
|
+ return 0;
|
|
+ }
|
|
+ i++;
|
|
+ if(!continuation_char(p_str->p_buf[i], &val)) return 0;
|
|
+TWO_REMAINING:
|
|
+ i++;
|
|
+ if(!continuation_char(p_str->p_buf[i], &val)) return 0;
|
|
+ i++;
|
|
+ if(!continuation_char(p_str->p_buf[i], &val)) return 0;
|
|
+ if(val < min || !unicode_valid(val)) return 0;
|
|
+ }
|
|
+ }
|
|
+ return 1;
|
|
+}
|
|
+
|
|
+
|
|
int
|
|
str_isempty(const struct mystr* p_str)
|
|
{
|
|
@@ -702,11 +759,13 @@
|
|
str_replace_unprintable(struct mystr* p_str, char new_char)
|
|
{
|
|
unsigned int i;
|
|
- for (i=0; i < p_str->len; i++)
|
|
- {
|
|
- if (!vsf_sysutil_isprint(p_str->p_buf[i]))
|
|
+ if( !str_is_utf8( p_str ) ) {
|
|
+ for (i=0; i < p_str->len; i++)
|
|
{
|
|
- p_str->p_buf[i] = new_char;
|
|
+ if (!vsf_sysutil_isprint(p_str->p_buf[i]))
|
|
+ {
|
|
+ p_str->p_buf[i] = new_char;
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
Index: str.h
|
|
===================================================================
|
|
--- str.h.orig 2008-12-17 06:53:23.000000000 +0100
|
|
+++ str.h 2012-04-10 16:10:59.965767345 +0200
|
|
@@ -36,6 +36,7 @@
|
|
void str_trunc(struct mystr* p_str, unsigned int trunc_len);
|
|
void str_reserve(struct mystr* p_str, unsigned int res_len);
|
|
|
|
+int str_is_utf8(const struct mystr* p_str);
|
|
int str_isempty(const struct mystr* p_str);
|
|
unsigned int str_getlen(const struct mystr* p_str);
|
|
const char* str_getbuf(const struct mystr* p_str);
|