}
void free_config(config_t *cfg) {
- if(cfg->variable) {
- free(cfg->variable);
- }
-
- if(cfg->value) {
- free(cfg->value);
- }
-
- if(cfg->file) {
- free(cfg->file);
- }
-
+ free(cfg->variable);
+ free(cfg->value);
+ free(cfg->file);
free(cfg);
}
return;
}
- snprintf(tmpfile, sizeof(tmpfile), "%s.tmp", filename);
+ int len = snprintf(tmpfile, sizeof(tmpfile), "%s.tmp", filename);
- w = fopen(tmpfile, "w");
+ if(len < 0 || len >= PATH_MAX) {
+ fprintf(stderr, "Pathname too long: %s.tmp\n", filename);
+ w = NULL;
+ } else {
+ w = fopen(tmpfile, "w");
+ }
while(fgets(buf, sizeof(buf), r)) {
if(!strncmp(buf, "-----BEGIN RSA", 14)) {