[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Remove assumptions that maximum path length is anything lik...
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] Remove assumptions that maximum path length is anything lik...
- From: nickm@xxxxxxxx (Nick Mathewson)
- Date: Tue, 22 Feb 2005 01:38:42 -0500 (EST)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Tue, 22 Feb 2005 01:39:31 -0500
- Reply-to: or-dev@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
Update of /home/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv5843/src/or
Modified Files:
config.c
Log Message:
Remove assumptions that maximum path length is anything like 1024. From comments by Chris Palmer
Index: config.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/config.c,v
retrieving revision 1.313
retrieving revision 1.314
diff -u -d -r1.313 -r1.314
--- config.c 22 Feb 2005 00:53:07 -0000 1.313
+++ config.c 22 Feb 2005 06:38:39 -0000 1.314
@@ -2307,7 +2307,6 @@
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 @@
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 @@
}
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);