- numFilters++;
- filters = (char **)realloc(filters, numFilters * sizeof(char *));
- filters[j] = (char *)malloc((strlen(arg) + 1) * sizeof(char *));
- snprintf(filters[j], strlen(arg) + 1, "%s", arg);
- j++;
+ unsigned int filter_len;
+ numFilters++;
+ /* Prepend a rule (and a comma) to enable the monitor to eavesdrop.
+ * Prepending allows the user to add eavesdrop=false at command line
+ * in order to disable eavesdropping when needed */
+ filter_len = strlen (EAVESDROPPING_RULE) + 1 + strlen (arg) + 1;
+
+ filters = (char **) realloc (filters, numFilters * sizeof (char *));
+ if (filters == NULL)
+ oom ("adding a new filter slot");
+ filters[j] = (char *) malloc (filter_len * sizeof (char *));
+ if (filters[j] == NULL)
+ oom ("adding a new filter");
+ snprintf (filters[j], filter_len, "%s,%s", EAVESDROPPING_RULE, arg);
+ j++;