diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-02-22 06:38:39 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-02-22 06:38:39 +0000 |
commit | d01718841e5bc3d365191e74bebbccee48c8b045 (patch) | |
tree | 9be6338daadcb3f8d16c025d479897ccdcf0f218 /src/or | |
parent | 7d9820e80db2bcb46a7ae5d65eb59a51a34d9495 (diff) | |
download | tor-d01718841e5bc3d365191e74bebbccee48c8b045.tar.gz tor-d01718841e5bc3d365191e74bebbccee48c8b045.zip |
Remove assumptions that maximum path length is anything like 1024. From comments by Chris Palmer
svn:r3652
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/config.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/or/config.c b/src/or/config.c index 47b292e465..aeaa538177 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -2307,7 +2307,6 @@ validate_data_directory(or_options_t *options) { static int write_configuration_file(const char *fname, or_options_t *options) { - char fn_tmp[1024]; char *old_val=NULL, *new_val=NULL, *new_conf=NULL; int rename_old = 0, r; size_t len; @@ -2340,9 +2339,14 @@ write_configuration_file(const char *fname, or_options_t *options) if (rename_old) { int i = 1; + size_t fn_tmp_len = strlen(fname)+32; + char *fn_tmp; + tor_assert(fn_tmp_len > strlen(fname)); /*check for overflow*/ + fn_tmp = tor_malloc(fn_tmp_len); while (1) { - if (tor_snprintf(fn_tmp, sizeof(fn_tmp), "%s.orig.%d", fname, i)<0) { - log_fn(LOG_WARN, "Filename too long"); + if (tor_snprintf(fn_tmp, fn_tmp_len, "%s.orig.%d", fname, i)<0) { + log_fn(LOG_WARN, "tor_snprintf failed inexplicably"); + tor_free(fn_tmp); goto err; } if (file_status(fn_tmp) == FN_NOENT) @@ -2351,6 +2355,7 @@ write_configuration_file(const char *fname, or_options_t *options) } log_fn(LOG_NOTICE, "Renaming old configuration file to %s", fn_tmp); rename(fname, fn_tmp); + tor_free(fn_tmp); } write_str_to_file(fname, new_val, 0); |