summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-05-18 15:35:21 +0000
committerNick Mathewson <nickm@torproject.org>2004-05-18 15:35:21 +0000
commit7511fbf993271312875d0648166694cc58117060 (patch)
tree57e08c4ab87356af3149d328cf56582ae8ad54a4 /src/common
parent9da1714676c018e1b4a8c5b52c7be7a5a6579243 (diff)
downloadtor-7511fbf993271312875d0648166694cc58117060.tar.gz
tor-7511fbf993271312875d0648166694cc58117060.zip
Resolve some XXXs
svn:r1889
Diffstat (limited to 'src/common')
-rw-r--r--src/common/tortls.c8
-rw-r--r--src/common/util.c23
-rw-r--r--src/common/util.h8
3 files changed, 33 insertions, 6 deletions
diff --git a/src/common/tortls.c b/src/common/tortls.c
index 8dc160702c..cfca993caf 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -375,7 +375,10 @@ tor_tls_context_new(crypto_pk_env_t *identity,
SSL_CTX_free(result->ctx);
if (result)
free(result);
- /* leak certs XXXX ? */
+ if (cert)
+ X509_free(cert);
+ if (idcert)
+ X509_free(cert);
return -1;
}
@@ -641,7 +644,8 @@ tor_tls_verify(tor_tls *tls, crypto_pk_env_t *identity_key)
if (id_pkey)
EVP_PKEY_free(id_pkey);
- /* XXXX This should never get invoked, but let's make sure for now. */
+ /* This should never get invoked, but let's make sure in case OpenSSL
+ * acts unexpectedly. */
tls_log_errors(LOG_WARN, "finishing tor_tls_verify");
return r;
diff --git a/src/common/util.c b/src/common/util.c
index d41b0e2728..727af645b0 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1323,7 +1323,28 @@ write_str_to_file(const char *fname, const char *str)
return -1;
}
fclose(file);
- /* XXXX This won't work on windows: you can't use rename to replace a file.*/
+
+#ifdef MS_WINDOWS
+ /* On Windows, rename doesn't replace. We could call ReplaceFile, but
+ * that's hard, and we can probably sneak by without atomicity. */
+ switch (file_status(fname)) {
+ case FN_ERROR:
+ log(LOG_WARN, "Error replacing %s: %s", fname, strerror(errno));
+ return -1;
+ case FN_DIR:
+ log(LOG_WARN, "Error replacing %s: is directory", fname);
+ return -1;
+ case FN_FILE:
+ if (unlink(fname)) {
+ log(LOG_WARN, "Error replacing %s while removing old copy: %s",
+ fname, strerror(errno));
+ return -1;
+ }
+ break;
+ case FN_NOENT:
+ ;
+ }
+#endif
if (rename(tempname, fname)) {
log(LOG_WARN, "Error replacing %s: %s", fname, strerror(errno));
return -1;
diff --git a/src/common/util.h b/src/common/util.h
index 04811abfa1..6f707ca729 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -77,10 +77,12 @@
#define tor_close_socket(s) close(s)
#endif
-
-/* XXXX This isn't so on windows. */
/** Legal characters in a filename */
-#define CONFIG_LEGAL_FILENAME_CHARACTERS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_/"
+#ifdef MS_WINDOWS
+#define CONFIG_LEGAL_FILENAME_CHARACTERS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_/\\ "
+#else
+#define CONFIG_LEGAL_FILENAME_CHARACTERS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_/ "
+#endif
size_t strlcat(char *dst, const char *src, size_t siz);
size_t strlcpy(char *dst, const char *src, size_t siz);