Browse Source

* fix warnings

master
Alex 'AdUser' Z 9 years ago
parent
commit
60e4782ebe
  1. 12
      src/config.c
  2. 4
      src/config.h
  3. 3
      src/filters/preg.c

12
src/config.c

@ -12,7 +12,7 @@ f2b_config_param_create(const char *src) {
size_t len;
strncpy(line, src, sizeof(line));
line[CONFIG_LINE_MAX] = '\0';
line[CONFIG_LINE_MAX - 1] = '\0';
/* strip spaces before key */
key = line;
@ -47,18 +47,18 @@ f2b_config_param_create(const char *src) {
p++, *p = '\0';
len = strlen(key);
if (len < 1 || len > CONFIG_KEY_MAX)
if (len < 1 || len >= CONFIG_KEY_MAX)
return NULL;
len = strlen(value);
if (len < 1 || len > CONFIG_VAL_MAX)
if (len < 1 || len >= CONFIG_VAL_MAX)
return NULL;
if ((param = calloc(1, sizeof(f2b_config_param_t))) != NULL) {
strncpy(param->name, key, sizeof(param->name));
strncpy(param->value, value, sizeof(param->value));
param->name[CONFIG_KEY_MAX] = '\0';
param->name[CONFIG_VAL_MAX] = '\0';
param->name [CONFIG_KEY_MAX - 1] = '\0';
param->value[CONFIG_VAL_MAX - 1] = '\0';
return param;
}
@ -109,7 +109,7 @@ f2b_config_section_create(const char *src) {
src++;
strncpy(line, src, sizeof(line));
line[CONFIG_LINE_MAX] = '\0';
line[CONFIG_LINE_MAX - 1] = '\0';
if ((end = strchr(line, ']')) == NULL)
return NULL;

4
src/config.h

@ -17,8 +17,8 @@ typedef enum f2b_section_type {
typedef struct f2b_config_param_t {
struct f2b_config_param_t *next;
char name[CONFIG_KEY_MAX + 1];
char value[CONFIG_VAL_MAX + 1];
char name[CONFIG_KEY_MAX];
char value[CONFIG_VAL_MAX];
} f2b_config_param_t;
typedef struct f2b_config_section_t {

3
src/filters/preg.c

@ -29,7 +29,7 @@ create(const char *id) {
if ((cfg = calloc(1, sizeof(cfg_t))) == NULL)
return NULL;
strncpy(cfg->id, id, sizeof(cfg->id));
cfg->id[sizeof(cfg->id)] = '\0';
cfg->id[sizeof(cfg->id) - 1] = '\0';
return cfg;
}
@ -113,6 +113,7 @@ match(cfg_t *cfg, const char *line, char *buf, size_t buf_size) {
assert(buf_size > match_len);
strncpy(buf, &line[match[1].rm_so], match_len);
buf[match_len] = '\0';
buf[buf_size] = '\0';
return true;
}

Loading…
Cancel
Save