Don't allow control characters other than LF, CR, TAB.
return -1;
}
+static inline bool CheckAscii(const char *str)
+{
+ for (size_t i = 0; i < strlen(str); i++) {
+ if (str[i] < 0x20) {
+ // LF CR TAB
+ if (str[i] == 0x0a || str[i] == 0x0d || str[i] == 0x09) {
+ continue;
+ }
+ return false;
+ } else if (str[i] == 0x7f) {
+ return false;
+ }
+ }
+ return true;
+}
+
/**
* \brief parse a signature
*
SCReturnInt(-1);
}
+ if (!CheckAscii(sigstr)) {
+ SCLogError("rule contains invalid (control) characters");
+ SCReturnInt(-1);
+ }
+
s->sig_str = SCStrdup(sigstr);
if (unlikely(s->sig_str == NULL)) {
SCReturnInt(-1);