The following issues were found
streaming/rrdpush.h
3 issues
Line: 47
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
unsigned int overflow:1;
int timeout, default_port;
usec_t reconnect_delay;
char connected_to[CONNECTED_TO_SIZE + 1]; // We don't know which proxy we connect to, passed back from socket.c
size_t begin;
size_t reconnects_counter;
size_t sent_bytes;
size_t sent_bytes_on_this_connection;
size_t send_attempts;
Reported by FlawFinder.
Line: 60
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
netdata_mutex_t mutex;
struct circular_buffer *buffer;
BUFFER *build;
char read_buffer[512];
int read_len;
int32_t version;
};
struct receiver_state {
Reported by FlawFinder.
Line: 86
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 update_every;
uint32_t stream_version;
time_t last_msg_t;
char read_buffer[1024]; // Need to allow RRD_ID_LENGTH_MAX * 4 + the other fields
int read_len;
#ifdef ENABLE_HTTPS
struct netdata_ssl ssl;
#endif
unsigned int shutdown:1; // Tell the thread to exit
Reported by FlawFinder.
streaming/rrdpush.c
3 issues
Line: 436
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
netdata_mutex_lock(&host->sender->mutex);
if(!host->rrdpush_sender_spawn) {
char tag[NETDATA_THREAD_TAG_MAX + 1];
snprintfz(tag, NETDATA_THREAD_TAG_MAX, "STREAM_SENDER[%s]", host->hostname);
if(netdata_thread_create(&host->rrdpush_sender_thread, tag, NETDATA_THREAD_OPTION_JOINABLE, rrdpush_sender_thread, (void *) host->sender))
error("STREAM %s [send]: failed to create new thread for client.", host->hostname);
else
Reported by FlawFinder.
Line: 471
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
int32_t utc_offset = 0;
int update_every = default_rrd_update_every;
uint32_t stream_version = UINT_MAX;
char buf[GUID_LEN + 1];
struct rrdhost_system_info *system_info = callocz(1, sizeof(struct rrdhost_system_info));
system_info->hops = 1;
while(url) {
char *value = mystrsep(&url, "&");
Reported by FlawFinder.
Line: 721
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
debug(D_SYSTEM, "starting STREAM receive thread.");
char tag[FILENAME_MAX + 1];
snprintfz(tag, FILENAME_MAX, "STREAM_RECEIVER[%s,[%s]:%s]", rpt->hostname, w->client_ip, w->client_port);
if(netdata_thread_create(&rpt->thread, tag, NETDATA_THREAD_OPTION_DEFAULT, rrdpush_receiver_thread, (void *)rpt))
error("Failed to create new STREAM receive thread for client.");
Reported by FlawFinder.
libnetdata/os.c
3 issues
Line: 35
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
return processors;
#else
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/proc/stat", netdata_configured_host_prefix);
procfile *ff = procfile_open(filename, NULL, PROCFILE_FLAG_DEFAULT);
if(!ff) {
error("Cannot open file '%s'. Assuming system has %d processors.", filename, processors);
Reported by FlawFinder.
Line: 92
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
if(unlikely(read)) return pid_max;
read = 1;
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/proc/sys/kernel/pid_max", netdata_configured_host_prefix);
unsigned long long max = 0;
if(read_single_number_file(filename, &max) != 0) {
error("Cannot open file '%s'. Assuming system supports %d pids.", filename, pid_max);
Reported by FlawFinder.
Line: 89
Column: 17
CWE codes:
120
20
#else
static char read = 0;
if(unlikely(read)) return pid_max;
read = 1;
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/proc/sys/kernel/pid_max", netdata_configured_host_prefix);
Reported by FlawFinder.
claim/claim.c
3 issues
Line: 59
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
#ifndef DISABLE_CLOUD
int exit_code;
pid_t command_pid;
char command_buffer[CLAIMING_COMMAND_LENGTH + 1];
FILE *fp;
// This is guaranteed to be set early in main via post_conf_load()
char *cloud_base_url = appconfig_get(&cloud_config, CONFIG_SECTION_GLOBAL, "cloud base url", NULL);
if (cloud_base_url == NULL)
Reported by FlawFinder.
Line: 68
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
fatal("Do not move the cloud base url out of post_conf_load!!");
const char *proxy_str;
ACLK_PROXY_TYPE proxy_type;
char proxy_flag[CLAIMING_PROXY_LENGTH] = "-noproxy";
proxy_str = aclk_get_proxy(&proxy_type);
if (proxy_type == PROXY_TYPE_SOCKS5 || proxy_type == PROXY_TYPE_HTTP)
snprintf(proxy_flag, CLAIMING_PROXY_LENGTH, "-proxy=\"%s\"", proxy_str);
Reported by FlawFinder.
Line: 152
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
// Propagate into aclk and registry. Be kind of atomic...
appconfig_get(&cloud_config, CONFIG_SECTION_GLOBAL, "cloud base url", DEFAULT_CLOUD_BASE_URL);
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/cloud.d/claimed_id", netdata_configured_varlib_dir);
long bytes_read;
char *claimed_id = read_by_filename(filename, &bytes_read);
if(claimed_id && uuid_parse(claimed_id, uuid)) {
Reported by FlawFinder.
backends/backends.c
3 issues
Line: 169
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
// after logging a simple of it to error.log
int discard_response(BUFFER *b, const char *backend) {
char sample[1024];
const char *s = buffer_tostring(b);
char *d = sample, *e = &sample[sizeof(sample) - 1];
for(; *s && d < e ;s++) {
char c = *s;
Reported by FlawFinder.
Line: 851
Column: 17
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
size_t sent = 0;
while(sent < buffer_len) {
char partition_key[KINESIS_PARTITION_KEY_MAX + 1];
snprintf(partition_key, KINESIS_PARTITION_KEY_MAX, "netdata_%llu", partition_key_seq++);
size_t partition_key_len = strnlen(partition_key, KINESIS_PARTITION_KEY_MAX);
const char *first_char = buffer_tostring(b) + sent;
Reported by FlawFinder.
Line: 868
Column: 17
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
while(*(first_char + record_len) != '\n' && record_len) record_len--;
}
char error_message[ERROR_LINE_MAX + 1] = "";
debug(D_BACKEND, "BACKEND: backends_kinesis_put_record(): dest = %s, id = %s, key = %s, stream = %s, partition_key = %s, \
buffer = %zu, record = %zu", destination, kinesis_auth_key_id, kinesis_secure_key, kinesis_stream_name,
partition_key, buffer_len, record_len);
Reported by FlawFinder.
spawn/spawn.c
3 issues
Line: 193
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 create_spawn_server(uv_loop_t *loop, uv_pipe_t *spawn_channel, uv_process_t *process)
{
uv_process_options_t options = {0};
char *args[3];
int ret;
#define SPAWN_SERVER_DESCRIPTORS (3)
uv_stdio_container_t stdio[SPAWN_SERVER_DESCRIPTORS];
struct passwd *passwd = NULL;
char *user = NULL;
Reported by FlawFinder.
Line: 269
Column: 13
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
uint64_t serial[CONCURRENT_SPAWNS];
for (int j = 0 ; j < SPAWN_ITERATIONS ; ++j) {
for (int i = 0; i < CONCURRENT_SPAWNS; ++i) {
char cmd[64];
sprintf(cmd, "echo CONCURRENT_STRESS_TEST %d 1>&2", j * CONCURRENT_SPAWNS + i + 1);
serial[i] = spawn_enq_cmd(cmd);
info("Queued command %s for spawning.", cmd);
}
int exit_status;
Reported by FlawFinder.
Line: 270
Column: 13
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
for (int j = 0 ; j < SPAWN_ITERATIONS ; ++j) {
for (int i = 0; i < CONCURRENT_SPAWNS; ++i) {
char cmd[64];
sprintf(cmd, "echo CONCURRENT_STRESS_TEST %d 1>&2", j * CONCURRENT_SPAWNS + i + 1);
serial[i] = spawn_enq_cmd(cmd);
info("Queued command %s for spawning.", cmd);
}
int exit_status;
time_t exec_run_timestamp;
Reported by FlawFinder.
collectors/proc.plugin/proc_net_softnet_stat.c
3 issues
Line: 30
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(unlikely(do_per_core == -1)) do_per_core = config_get_boolean("plugin:proc:/proc/net/softnet_stat", "softnet_stat per core", 1);
if(unlikely(!ff)) {
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/softnet_stat");
ff = procfile_open(config_get("plugin:proc:/proc/net/softnet_stat", "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
if(unlikely(!ff)) return 1;
}
Reported by FlawFinder.
Line: 114
Column: 13
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(do_per_core) {
for(l = 0; l < lines ;l++) {
char id[50+1];
snprintfz(id, 50, "cpu%zu_softnet_stat", l);
st = rrdset_find_active_bytype_localhost("cpu", id);
if(unlikely(!st)) {
char title[100+1];
Reported by FlawFinder.
Line: 119
Column: 17
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
st = rrdset_find_active_bytype_localhost("cpu", id);
if(unlikely(!st)) {
char title[100+1];
snprintfz(title, 100, "CPU%zu softnet_stat", l);
st = rrdset_create_localhost(
"cpu"
, id
Reported by FlawFinder.
collectors/ebpf.plugin/ebpf_filesystem.c
3 issues
Line: 123
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 void ebpf_create_fs_charts()
{
static int order = NETDATA_CHART_PRIO_EBPF_FILESYSTEM_CHARTS;
char chart_name[64], title[256], family[64];
int i;
uint32_t test = NETDATA_FILESYSTEM_FLAG_CHART_CREATED|NETDATA_FILESYSTEM_REMOVE_CHARTS;
for (i = 0; localfs[i].filesystem; i++) {
ebpf_filesystem_partitions_t *efp = &localfs[i];
uint32_t flags = efp->flags;
Reported by FlawFinder.
Line: 247
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 int ebpf_read_local_partitions()
{
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/proc/self/mountinfo", netdata_configured_host_prefix);
procfile *ff = procfile_open(filename, " \t", PROCFILE_FLAG_DEFAULT);
if(unlikely(!ff)) {
snprintfz(filename, FILENAME_MAX, "%s/proc/1/mountinfo", netdata_configured_host_prefix);
ff = procfile_open(filename, " \t", PROCFILE_FLAG_DEFAULT);
Reported by FlawFinder.
Line: 582
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 void ebpf_update_filesystem()
{
char dist[NETDATA_FS_MAX_DIST_NAME + 1];
int i;
for (i = 0; localfs[i].filesystem; i++) {
snprintfz(dist, NETDATA_FS_MAX_DIST_NAME, "%sdist", localfs[i].filesystem);
localfs[i].enabled = appconfig_get_boolean(&fs_config, NETDATA_FILESYSTEM_CONFIG_NAME, dist,
Reported by FlawFinder.
backends/aws_kinesis/aws_kinesis.c
3 issues
Line: 27
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 line = 0;
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/aws_kinesis.conf", path);
char buffer[CONFIG_FILE_LINE_MAX + 1], *s;
debug(D_BACKEND, "BACKEND: opening config file '%s'", filename);
Reported by FlawFinder.
Line: 30
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 filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/aws_kinesis.conf", path);
char buffer[CONFIG_FILE_LINE_MAX + 1], *s;
debug(D_BACKEND, "BACKEND: opening config file '%s'", filename);
FILE *fp = fopen(filename, "r");
if(!fp) {
Reported by FlawFinder.
Line: 34
Column: 16
CWE codes:
362
debug(D_BACKEND, "BACKEND: opening config file '%s'", filename);
FILE *fp = fopen(filename, "r");
if(!fp) {
return 1;
}
while(fgets(buffer, CONFIG_FILE_LINE_MAX, fp) != NULL) {
Reported by FlawFinder.
collectors/proc.plugin/ipc.c
3 issues
Line: 76
Column: 12
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 inline int ipc_sem_get_limits(struct ipc_limits *lim) {
static procfile *ff = NULL;
static int error_shown = 0;
static char filename[FILENAME_MAX + 1] = "";
if(unlikely(!filename[0]))
snprintfz(filename, FILENAME_MAX, "%s/proc/sys/kernel/sem", netdata_configured_host_prefix);
if(unlikely(!ff)) {
Reported by FlawFinder.
Line: 297
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
do_sem = config_get_boolean("plugin:proc:ipc", "semaphore totals", CONFIG_BOOLEAN_YES);
do_shm = config_get_boolean("plugin:proc:ipc", "shared memory totals", CONFIG_BOOLEAN_YES);
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/sysvipc/msg");
msg_filename = config_get("plugin:proc:ipc", "msg filename to monitor", filename);
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/sysvipc/shm");
Reported by FlawFinder.
Line: 450
Column: 25
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
while(likely(msq)){
if(likely(msq->found)) {
if(unlikely(!msq->rd_messages || !msq->rd_bytes)) {
char id[RRD_ID_LENGTH_MAX + 1];
snprintfz(id, RRD_ID_LENGTH_MAX, "%llu", msq->id);
if(likely(!msq->rd_messages)) msq->rd_messages = rrddim_add(st_msq_messages, id, NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
if(likely(!msq->rd_bytes)) msq->rd_bytes = rrddim_add(st_msq_bytes, id, NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
}
Reported by FlawFinder.