]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
stats: fix crash when stats.get/set is called with invalid parameters
authorPetr Špaček <petr.spacek@nic.cz>
Tue, 11 Dec 2018 16:03:13 +0000 (17:03 +0100)
committerPetr Špaček <petr.spacek@nic.cz>
Tue, 11 Dec 2018 16:05:10 +0000 (17:05 +0100)
Closes: #186
modules/stats/stats.c

index 96a5ba37dae0b057f590ecb7f24212cf2666b2f5..04c95771422a61f057ec51c8176a519d012b2f36 100644 (file)
@@ -277,7 +277,11 @@ static int collect(kr_layer_t *ctx)
  */
 static char* stats_set(void *env, struct kr_module *module, const char *args)
 {
+       if (args == NULL)
+               return NULL;
+
        struct stat_data *data = module->data;
+
        auto_free char *pair = strdup(args);
        char *val = strchr(pair, ' ');
        if (val) {
@@ -303,6 +307,9 @@ static char* stats_set(void *env, struct kr_module *module, const char *args)
  */
 static char* stats_get(void *env, struct kr_module *module, const char *args)
 {
+       if (args == NULL)
+               return NULL;
+
        struct stat_data *data = module->data;
 
        /* Expecting CHAR_BIT to be 8, this is a safe bet */