From: Petr Špaček Date: Tue, 11 Dec 2018 16:03:13 +0000 (+0100) Subject: stats: fix crash when stats.get/set is called with invalid parameters X-Git-Tag: v3.2.0~11^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e38f078c8617ca3a76992e8be9b9424a016032c9;p=thirdparty%2Fknot-resolver.git stats: fix crash when stats.get/set is called with invalid parameters Closes: #186 --- diff --git a/modules/stats/stats.c b/modules/stats/stats.c index 96a5ba37d..04c957714 100644 --- a/modules/stats/stats.c +++ b/modules/stats/stats.c @@ -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 */