about summary refs log tree commit diff
path: root/src/base/system.c
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2010-08-12 15:22:07 +0200
committeroy <Tom_Adams@web.de>2010-08-12 15:22:07 +0200
commit7503c642379cec7a2e14fe6a516d69a1f4d6d94a (patch)
tree7c10ada1c341c67669cccdc7ae6f261ae3d103a6 /src/base/system.c
parent1cde96ef79a8418a9c34f355ec49d08f1e654213 (diff)
downloadzcatch-7503c642379cec7a2e14fe6a516d69a1f4d6d94a.tar.gz
zcatch-7503c642379cec7a2e14fe6a516d69a1f4d6d94a.zip
made unpacking of net strings more strict - prevents possible malformed output
Diffstat (limited to 'src/base/system.c')
-rw-r--r--src/base/system.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/base/system.c b/src/base/system.c
index 457b761a..84f732e7 100644
--- a/src/base/system.c
+++ b/src/base/system.c
@@ -1092,6 +1092,18 @@ void str_sanitize_strong(char *str_in)
 	}
 }
 
+/* makes sure that the string only contains the characters between 32 and 255 */
+void str_sanitize_cc(char *str_in)
+{
+	unsigned char *str = (unsigned char *)str_in;
+	while(*str)
+	{
+		if(*str < 32)
+			*str = ' ';
+		str++;
+	}
+}
+
 /* makes sure that the string only contains the characters between 32 and 255 + \r\n\t */
 void str_sanitize(char *str_in)
 {
@@ -1104,6 +1116,13 @@ void str_sanitize(char *str_in)
 	}
 }
 
+char *str_skip_whitespaces(char *str)
+{
+	while(*str && (*str == ' ' || *str == '\t' || *str == '\n' || *str == '\r'))
+		str++;
+	return str;
+}
+
 /* case */
 int str_comp_nocase(const char *a, const char *b)
 {