Fix Coverity defects (#6008)
Vladimir Kobal committed
May 14, 2019 at 13:48 UTC
1833691018fda9eb6b80eed373c482a394a1267e
1 file changed
+10
streaming/rrdpush.c
+10
@@ -1185,36 +1185,42 @@ int rrdpush_receiver_thread_spawn(RRDHOST *host, struct web_client *w, char *url
1185
}
1186
1187
if(!key || !*key) {
1188
+ rrdhost_system_info_free(system_info);
1189
log_stream_connection(w->client_ip, w->client_port, (key && *key)?key:"-", (machine_guid && *machine_guid)?machine_guid:"-", (hostname && *hostname)?hostname:"-", "ACCESS DENIED - NO KEY");
1190
error("STREAM [receive from [%s]:%s]: request without an API key. Forbidding access.", w->client_ip, w->client_port);
1191
return rrdpush_receiver_permission_denied(w);
1192
}
1193
1194
if(!hostname || !*hostname) {
1195
+ rrdhost_system_info_free(system_info);
1196
log_stream_connection(w->client_ip, w->client_port, (key && *key)?key:"-", (machine_guid && *machine_guid)?machine_guid:"-", (hostname && *hostname)?hostname:"-", "ACCESS DENIED - NO HOSTNAME");
1197
error("STREAM [receive from [%s]:%s]: request without a hostname. Forbidding access.", w->client_ip, w->client_port);
1198
return rrdpush_receiver_permission_denied(w);
1199
}
1200
1201
if(!machine_guid || !*machine_guid) {
1202
+ rrdhost_system_info_free(system_info);
1203
log_stream_connection(w->client_ip, w->client_port, (key && *key)?key:"-", (machine_guid && *machine_guid)?machine_guid:"-", (hostname && *hostname)?hostname:"-", "ACCESS DENIED - NO MACHINE GUID");
1204
error("STREAM [receive from [%s]:%s]: request without a machine GUID. Forbidding access.", w->client_ip, w->client_port);
1205
return rrdpush_receiver_permission_denied(w);
1206
}
1207
1208
if(regenerate_guid(key, buf) == -1) {
1209
+ rrdhost_system_info_free(system_info);
1210
log_stream_connection(w->client_ip, w->client_port, (key && *key)?key:"-", (machine_guid && *machine_guid)?machine_guid:"-", (hostname && *hostname)?hostname:"-", "ACCESS DENIED - INVALID KEY");
1211
error("STREAM [receive from [%s]:%s]: API key '%s' is not valid GUID (use the command uuidgen to generate one). Forbidding access.", w->client_ip, w->client_port, key);
1212
return rrdpush_receiver_permission_denied(w);
1213
}
1214
1215
if(regenerate_guid(machine_guid, buf) == -1) {
1216
+ rrdhost_system_info_free(system_info);
1217
log_stream_connection(w->client_ip, w->client_port, (key && *key)?key:"-", (machine_guid && *machine_guid)?machine_guid:"-", (hostname && *hostname)?hostname:"-", "ACCESS DENIED - INVALID MACHINE GUID");
1218
error("STREAM [receive from [%s]:%s]: machine GUID '%s' is not GUID. Forbidding access.", w->client_ip, w->client_port, machine_guid);
1219
return rrdpush_receiver_permission_denied(w);
1220
}
1221
1222
if(!appconfig_get_boolean(&stream_config, key, "enabled", 0)) {
1223
+ rrdhost_system_info_free(system_info);
1224
log_stream_connection(w->client_ip, w->client_port, (key && *key)?key:"-", (machine_guid && *machine_guid)?machine_guid:"-", (hostname && *hostname)?hostname:"-", "ACCESS DENIED - KEY NOT ENABLED");
1225
error("STREAM [receive from [%s]:%s]: API key '%s' is not allowed. Forbidding access.", w->client_ip, w->client_port, key);
1226
return rrdpush_receiver_permission_denied(w);
@@ -1225,6 +1231,7 @@ int rrdpush_receiver_thread_spawn(RRDHOST *host, struct web_client *w, char *url
1231
if(key_allow_from) {
1232
if(!simple_pattern_matches(key_allow_from, w->client_ip)) {
1233
simple_pattern_free(key_allow_from);
1234
+ rrdhost_system_info_free(system_info);
1235
log_stream_connection(w->client_ip, w->client_port, (key && *key)?key:"-", (machine_guid && *machine_guid)?machine_guid:"-", (hostname && *hostname) ? hostname : "-", "ACCESS DENIED - KEY NOT ALLOWED FROM THIS IP");
1236
error("STREAM [receive from [%s]:%s]: API key '%s' is not permitted from this IP. Forbidding access.", w->client_ip, w->client_port, key);
1237
return rrdpush_receiver_permission_denied(w);
@@ -1234,6 +1241,7 @@ int rrdpush_receiver_thread_spawn(RRDHOST *host, struct web_client *w, char *url
1241
}
1242
1243
if(!appconfig_get_boolean(&stream_config, machine_guid, "enabled", 1)) {
1244
+ rrdhost_system_info_free(system_info);
1245
log_stream_connection(w->client_ip, w->client_port, (key && *key)?key:"-", (machine_guid && *machine_guid)?machine_guid:"-", (hostname && *hostname)?hostname:"-", "ACCESS DENIED - MACHINE GUID NOT ENABLED");
1246
error("STREAM [receive from [%s]:%s]: machine GUID '%s' is not allowed. Forbidding access.", w->client_ip, w->client_port, machine_guid);
1247
return rrdpush_receiver_permission_denied(w);
@@ -1244,6 +1252,7 @@ int rrdpush_receiver_thread_spawn(RRDHOST *host, struct web_client *w, char *url
1252
if(machine_allow_from) {
1253
if(!simple_pattern_matches(machine_allow_from, w->client_ip)) {
1254
simple_pattern_free(machine_allow_from);
1255
+ rrdhost_system_info_free(system_info);
1256
log_stream_connection(w->client_ip, w->client_port, (key && *key)?key:"-", (machine_guid && *machine_guid)?machine_guid:"-", (hostname && *hostname) ? hostname : "-", "ACCESS DENIED - MACHINE GUID NOT ALLOWED FROM THIS IP");
1257
error("STREAM [receive from [%s]:%s]: Machine GUID '%s' is not permitted from this IP. Forbidding access.", w->client_ip, w->client_port, machine_guid);
1258
return rrdpush_receiver_permission_denied(w);
@@ -1264,6 +1273,7 @@ int rrdpush_receiver_thread_spawn(RRDHOST *host, struct web_client *w, char *url
1273
1274
if(now - last_stream_accepted_t < web_client_streaming_rate_t) {
1275
netdata_mutex_unlock(&stream_rate_mutex);
1276
+ rrdhost_system_info_free(system_info);
1277
error("STREAM [receive from [%s]:%s]: too busy to accept new streaming request. Will be allowed in %ld secs.", w->client_ip, w->client_port, (long)(web_client_streaming_rate_t - (now - last_stream_accepted_t)));
1278
return rrdpush_receiver_too_busy_now(w);
1279
}