The following issues were found
registry/registry_log.c
4 issues
Line: 33
Column: 23
CWE codes:
362
if(registry.log_fp)
fclose(registry.log_fp);
registry.log_fp = fopen(registry.log_filename, "a");
if(registry.log_fp) {
if (setvbuf(registry.log_fp, NULL, _IOLBF, 0) != 0)
error("Cannot set line buffering on registry log file.");
return 0;
}
Reported by FlawFinder.
Line: 56
Column: 27
CWE codes:
362
registry_log_close();
// open it with truncate
registry.log_fp = fopen(registry.log_filename, "w");
if(registry.log_fp) fclose(registry.log_fp);
else error("Cannot truncate registry log '%s'", registry.log_filename);
registry.log_fp = NULL;
registry_log_open();
Reported by FlawFinder.
Line: 73
Column: 16
CWE codes:
362
registry_log_close();
debug(D_REGISTRY, "Registry: loading active db from: %s", registry.log_filename);
FILE *fp = fopen(registry.log_filename, "r");
if(!fp)
error("Registry: cannot open registry file: %s", registry.log_filename);
else {
char *s, buf[4096 + 1];
line = 0;
Reported by FlawFinder.
Line: 77
Column: 9
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
if(!fp)
error("Registry: cannot open registry file: %s", registry.log_filename);
else {
char *s, buf[4096 + 1];
line = 0;
size_t len = 0;
while ((s = fgets_trim_len(buf, 4096, fp, &len))) {
line++;
Reported by FlawFinder.
parser/parser.h
4 issues
Line: 80
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
char *(*read_function)(char *buffer, long unsigned int, void *input);
int (*eof_function)(void *input);
keyword_function unknown_function;
char buffer[PLUGINSD_LINE_MAX];
char *recover_location[PARSER_MAX_RECOVER_KEYWORDS+1];
char recover_input[PARSER_MAX_RECOVER_KEYWORDS];
#ifdef ENABLE_HTTPS
int bytesleft;
char tmpbuffer[PLUGINSD_LINE_MAX];
Reported by FlawFinder.
Line: 81
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
int (*eof_function)(void *input);
keyword_function unknown_function;
char buffer[PLUGINSD_LINE_MAX];
char *recover_location[PARSER_MAX_RECOVER_KEYWORDS+1];
char recover_input[PARSER_MAX_RECOVER_KEYWORDS];
#ifdef ENABLE_HTTPS
int bytesleft;
char tmpbuffer[PLUGINSD_LINE_MAX];
char *readfrom;
Reported by FlawFinder.
Line: 82
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
keyword_function unknown_function;
char buffer[PLUGINSD_LINE_MAX];
char *recover_location[PARSER_MAX_RECOVER_KEYWORDS+1];
char recover_input[PARSER_MAX_RECOVER_KEYWORDS];
#ifdef ENABLE_HTTPS
int bytesleft;
char tmpbuffer[PLUGINSD_LINE_MAX];
char *readfrom;
#endif
Reported by FlawFinder.
Line: 85
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
char recover_input[PARSER_MAX_RECOVER_KEYWORDS];
#ifdef ENABLE_HTTPS
int bytesleft;
char tmpbuffer[PLUGINSD_LINE_MAX];
char *readfrom;
#endif
} PARSER;
PARSER *parser_init(RRDHOST *host, void *user, void *input, PARSER_INPUT_TYPE flags);
Reported by FlawFinder.
collectors/python.d.plugin/exim/exim.chart.py
4 issues
Line: 6
Column: 1
# Author: Pawel Krupa (paulfantom)
# SPDX-License-Identifier: GPL-3.0-or-later
from bases.FrameworkServices.ExecutableService import ExecutableService
EXIM_COMMAND = 'exim -bpc'
ORDER = [
'qemails',
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description: exim netdata python.d module
# Author: Pawel Krupa (paulfantom)
# SPDX-License-Identifier: GPL-3.0-or-later
from bases.FrameworkServices.ExecutableService import ExecutableService
EXIM_COMMAND = 'exim -bpc'
Reported by Pylint.
Line: 24
Column: 1
}
class Service(ExecutableService):
def __init__(self, configuration=None, name=None):
ExecutableService.__init__(self, configuration=configuration, name=name)
self.order = ORDER
self.definitions = CHARTS
self.command = EXIM_COMMAND
Reported by Pylint.
Line: 24
Column: 1
}
class Service(ExecutableService):
def __init__(self, configuration=None, name=None):
ExecutableService.__init__(self, configuration=configuration, name=name)
self.order = ORDER
self.definitions = CHARTS
self.command = EXIM_COMMAND
Reported by Pylint.
database/engine/rrddiskprotocol.h
4 issues
Line: 28
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
* Data file persistent super-block
*/
struct rrdeng_df_sb {
char magic_number[RRDENG_MAGIC_SZ];
char version[RRDENG_VER_SZ];
uint8_t tier;
uint8_t padding[RRDENG_DF_SB_PADDING_SZ];
} __attribute__ ((packed));
Reported by FlawFinder.
Line: 29
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
*/
struct rrdeng_df_sb {
char magic_number[RRDENG_MAGIC_SZ];
char version[RRDENG_VER_SZ];
uint8_t tier;
uint8_t padding[RRDENG_DF_SB_PADDING_SZ];
} __attribute__ ((packed));
/*
Reported by FlawFinder.
Line: 75
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
* Journal file super-block
*/
struct rrdeng_jf_sb {
char magic_number[RRDENG_MAGIC_SZ];
char version[RRDENG_VER_SZ];
uint8_t padding[RRDENG_JF_SB_PADDING_SZ];
} __attribute__ ((packed));
/*
Reported by FlawFinder.
Line: 76
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
*/
struct rrdeng_jf_sb {
char magic_number[RRDENG_MAGIC_SZ];
char version[RRDENG_VER_SZ];
uint8_t padding[RRDENG_JF_SB_PADDING_SZ];
} __attribute__ ((packed));
/*
* Transaction record types
Reported by FlawFinder.
collectors/freeipmi.plugin/freeipmi_plugin.c
4 issues
Line: 1309
Column: 18
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
const char *event_direction_str;
const char *sel_state_str;
char *sensor_name = NULL;
unsigned char oem_data[64];
int oem_data_len;
unsigned int j;
#endif // NETDATA_COMMENTED
if ((record_id = ipmi_monitoring_sel_read_record_id (ctx)) < 0)
Reported by FlawFinder.
Line: 724
Column: 59
CWE codes:
126
sn->sensor_reading_type = sensor_reading_type;
sn->sensor_name = strdup(sensor_name);
if(!sn->sensor_name) {
fatal("cannot allocate %zu bytes of memory.", strlen(sensor_name));
}
sn->next = sensors_root;
sensors_root = sn;
}
Reported by FlawFinder.
Line: 1049
Column: 14
CWE codes:
126
);
#ifdef NETDATA_COMMENTED
if (!strlen (sensor_name))
sensor_name = "N/A";
sensor_type_str = _get_sensor_type_string (sensor_type);
printf ("%d, %s, %d, %s",
Reported by FlawFinder.
Line: 1462
Column: 18
CWE codes:
126
goto cleanup;
}
if (!strlen (sensor_name))
sensor_name = "N/A";
sensor_type_str = _get_sensor_type_string (sensor_type);
if (event_direction == IPMI_MONITORING_SEL_EVENT_DIRECTION_ASSERTION)
Reported by FlawFinder.
collectors/python.d.plugin/python_modules/urllib3/fields.py
4 issues
Line: 6
Column: 1
import email.utils
import mimetypes
from .packages import six
def guess_content_type(filename, default='application/octet-stream'):
"""
Guess the "Content-Type" of a file.
Reported by Pylint.
Line: 1
Column: 1
# SPDX-License-Identifier: MIT
from __future__ import absolute_import
import email.utils
import mimetypes
from .packages import six
def guess_content_type(filename, default='application/octet-stream'):
Reported by Pylint.
Line: 51
Column: 1
return value
class RequestField(object):
"""
A data container for request body parameters.
:param name:
The name of this request field.
Reported by Pylint.
Line: 106
Column: 5
return request_param
def _render_part(self, name, value):
"""
Overridable helper function to format a single header parameter.
:param name:
The name of the parameter, a string expected to be ASCII only.
Reported by Pylint.
libnetdata/socket/security.c
4 issues
Line: 153
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
*/
static SSL_CTX * security_initialize_openssl_server() {
SSL_CTX *ctx;
char lerror[512];
static int netdata_id_context = 1;
//TO DO: Confirm the necessity to check return for other OPENSSL function
#if OPENSSL_VERSION_NUMBER < OPENSSL_VERSION_110
ctx = SSL_CTX_new(SSLv23_server_method());
Reported by FlawFinder.
Line: 295
Column: 18
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
default:
{
u_long err;
char buf[256];
int counter = 0;
while ((err = ERR_get_error()) != 0) {
ERR_error_string_n(err, buf, sizeof(buf));
info("%d SSL Handshake error (%s) on socket %d ", counter++, ERR_error_string((long)SSL_get_error(ssl, test), NULL), sock);
}
Reported by FlawFinder.
Line: 334
Column: 9
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
status = SSL_get_verify_result(ssl);
if((X509_V_OK != status))
{
char error[512];
ERR_error_string_n(ERR_get_error(), error, sizeof(error));
error("SSL RFC4158 check: We have a invalid certificate, the tests result with %ld and message %s", status, error);
ret = -1;
} else {
ret = 0;
Reported by FlawFinder.
Line: 366
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
ERR_clear_error();
u_long err;
char buf[256];
if(!SSL_CTX_load_verify_locations(ctx, file, path)) {
goto slfc;
}
if(!SSL_CTX_set_default_verify_paths(ctx)) {
Reported by FlawFinder.
collectors/freebsd.plugin/freebsd_ipfw.c
4 issues
Line: 49
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
struct ip_fw_bcounter *cntr;
int c = 0;
char rule_num_str[12];
// variables for dynamic rules handling
caddr_t dynbase = NULL;
size_t dynsz = 0;
Reported by FlawFinder.
Line: 236
Column: 21
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
break;
if (likely(do_static)) {
sprintf(rule_num_str, "%d_%d", rule->rulenum, rule->id);
rd_packets = rrddim_find_active(st_packets, rule_num_str);
if (unlikely(!rd_packets))
rd_packets = rrddim_add(st_packets, rule_num_str, NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
rrddim_set_by_pointer(st_packets, rd_packets, cntr->pcnt);
Reported by FlawFinder.
Line: 285
Column: 17
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
break;
dyn_rule = (ipfw_dyn_rule *) (tlv + 1);
bcopy(&dyn_rule->rule, &rulenum, sizeof(rulenum));
for (srn = 0; srn < (static_rules_num - 1); srn++) {
if (dyn_rule->expire > 0)
dyn_rules_counter = &dyn_rules_num[srn].active_rules;
else
Reported by FlawFinder.
Line: 348
Column: 17
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
rrdset_next(st_expired);
for (srn = 0; (srn < (static_rules_num - 1)) && (dyn_rules_num[srn].rule_num != IPFW_DEFAULT_RULE); srn++) {
sprintf(rule_num_str, "%d", dyn_rules_num[srn].rule_num);
rd_active = rrddim_find_active(st_active, rule_num_str);
if (unlikely(!rd_active))
rd_active = rrddim_add(st_active, rule_num_str, NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
rrddim_set_by_pointer(st_active, rd_active, dyn_rules_num[srn].active_rules);
Reported by FlawFinder.
collectors/python.d.plugin/python_modules/urllib3/filepost.py
4 issues
Line: 8
Column: 1
from uuid import uuid4
from io import BytesIO
from .packages import six
from .packages.six import b
from .fields import RequestField
writer = codecs.lookup('utf-8')[3]
Reported by Pylint.
Line: 9
Column: 1
from io import BytesIO
from .packages import six
from .packages.six import b
from .fields import RequestField
writer = codecs.lookup('utf-8')[3]
Reported by Pylint.
Line: 10
Column: 1
from .packages import six
from .packages.six import b
from .fields import RequestField
writer = codecs.lookup('utf-8')[3]
def choose_boundary():
Reported by Pylint.
Line: 1
Column: 1
# SPDX-License-Identifier: MIT
from __future__ import absolute_import
import codecs
from uuid import uuid4
from io import BytesIO
from .packages import six
from .packages.six import b
Reported by Pylint.
database/rrdcalc.c
4 issues
Line: 72
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
rc->local = rrdvar_create_and_index("local", &st->rrdvar_root_index, rc->name, RRDVAR_TYPE_CALCULATED, RRDVAR_OPTION_RRDCALC_LOCAL_VAR, &rc->value);
rc->family = rrdvar_create_and_index("family", &st->rrdfamily->rrdvar_root_index, rc->name, RRDVAR_TYPE_CALCULATED, RRDVAR_OPTION_RRDCALC_FAMILY_VAR, &rc->value);
char fullname[RRDVAR_MAX_LENGTH + 1];
snprintfz(fullname, RRDVAR_MAX_LENGTH, "%s.%s", st->id, rc->name);
rc->hostid = rrdvar_create_and_index("host", &host->rrdvar_root_index, fullname, RRDVAR_TYPE_CALCULATED, RRDVAR_OPTION_RRDCALC_HOST_CHARTID_VAR, &rc->value);
snprintfz(fullname, RRDVAR_MAX_LENGTH, "%s.%s", st->name, rc->name);
rc->hostname = rrdvar_create_and_index("host", &host->rrdvar_root_index, fullname, RRDVAR_TYPE_CALCULATED, RRDVAR_OPTION_RRDCALC_HOST_CHARTNAME_VAR, &rc->value);
Reported by FlawFinder.
Line: 297
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
newname = malloc(namelen + dimlen + 2);
if(newname) {
move = newname;
memcpy(move, name, namelen);
move += namelen;
*move++ = '_';
memcpy(move, dim, dimlen);
move += dimlen;
Reported by FlawFinder.
Line: 301
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
move += namelen;
*move++ = '_';
memcpy(move, dim, dimlen);
move += dimlen;
*move = '\0';
} else {
newname = name;
}
Reported by FlawFinder.
Line: 670
Column: 9
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
continue;
}
char cmp[CONFIG_FILE_LINE_MAX+1];
struct label *move = host->labels.head;
while(move) {
snprintf(cmp, CONFIG_FILE_LINE_MAX, "%s=%s", move->key, move->value);
if (simple_pattern_matches(rc->splabels, move->key) ||
simple_pattern_matches(rc->splabels, cmp)) {
Reported by FlawFinder.