return 0;
}
+static int collecty_queue_valid_object(collecty_queue* queue, const char* object) {
+ // Check for any invalid characters
+ for (const char* p = object; *p; p++) {
+ switch (*p) {
+ // Whitespace is not allowed
+ case ' ':
+ case '\t':
+ case '\n':
+ break;
+
+ // Slashes are not allowed
+ case '/':
+ case '\\':
+ break;
+
+ // Quotes are not allowed
+ case '"':
+ case '\'':
+ break;
+
+ // The rest is allowed
+ default:
+ continue;
+ }
+
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
/*
Submits a new reading into the queue
*/
if (!sample)
return -EINVAL;
+ // Check if the object is valid
+ if (object) {
+ r = collecty_queue_valid_object(self, object);
+ if (r < 0) {
+ ERROR(self->ctx, "%s has submitted an invalid object: %s\n",
+ collecty_source_name(source), object);
+ goto ERROR;
+ }
+ }
+
// Check if we can append the sample
o = collecty_queue_find_object(self, source, object);
if (o)