Browse Source

* use snprintf() instead strncpy() where possible

master
Alex 'AdUser' Z 9 years ago
parent
commit
9a118ad696
  1. 3
      src/backends/exec.c
  2. 3
      src/filters/preg.c

3
src/backends/exec.c

@ -155,8 +155,7 @@ create(const char *id) {
if ((cfg = calloc(1, sizeof(cfg_t))) == NULL) if ((cfg = calloc(1, sizeof(cfg_t))) == NULL)
return NULL; return NULL;
strncpy(cfg->name, id, sizeof(cfg->name)); snprintf(cfg->name, sizeof(cfg->name), "%s", id);
cfg->name[ID_MAX] = '\0';
return cfg; return cfg;
} }

3
src/filters/preg.c

@ -35,8 +35,7 @@ create(const char *id) {
if ((cfg = calloc(1, sizeof(cfg_t))) == NULL) if ((cfg = calloc(1, sizeof(cfg_t))) == NULL)
return NULL; return NULL;
strncpy(cfg->id, id, sizeof(cfg->id)); snprintf(cfg->id, sizeof(cfg->id), "%s", id);
cfg->id[sizeof(cfg->id) - 1] = '\0';
return cfg; return cfg;
} }

Loading…
Cancel
Save