[or-cvs] Resolve some XXXs

Nick Mathewson nickm at seul.org
Tue May 18 15:35:23 UTC 2004


Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/tmp/cvs-serv29718/src/common

Modified Files:
	tortls.c util.c util.h 
Log Message:
Resolve some XXXs

Index: tortls.c
===================================================================
RCS file: /home/or/cvsroot/src/common/tortls.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- tortls.c	10 May 2004 10:27:52 -0000	1.56
+++ tortls.c	18 May 2004 15:35:21 -0000	1.57
@@ -375,7 +375,10 @@
     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 @@
   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;

Index: util.c
===================================================================
RCS file: /home/or/cvsroot/src/common/util.c,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -d -r1.101 -r1.102
--- util.c	7 May 2004 17:04:11 -0000	1.101
+++ util.c	18 May 2004 15:35:21 -0000	1.102
@@ -1323,7 +1323,28 @@
     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;

Index: util.h
===================================================================
RCS file: /home/or/cvsroot/src/common/util.h,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- util.h	10 May 2004 07:54:13 -0000	1.68
+++ util.h	18 May 2004 15:35:21 -0000	1.69
@@ -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);



More information about the tor-commits mailing list