[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] put quotes around user-supplied strings so they are more li...



Update of /home2/or/cvsroot/tor/src/common
In directory moria:/home/arma/work/onion/cvs/tor/src/common

Modified Files:
	compat.c crypto.c tortls.c util.c 
Log Message:
put quotes around user-supplied strings so they are more likely to
realize if they add bad characters (like quotes) to the torrc


Index: compat.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/common/compat.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- compat.c	26 Aug 2005 07:37:07 -0000	1.65
+++ compat.c	26 Aug 2005 18:40:44 -0000	1.66
@@ -533,7 +533,7 @@
   tor_assert(username);
 
   if (!(pw = getpwnam(username))) {
-    log_fn(LOG_ERR,"User '%s' not found.", username);
+    log_fn(LOG_ERR,"User \"%s\" not found.", username);
     return NULL;
   }
   return tor_strdup(pw->pw_dir);

Index: crypto.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/common/crypto.c,v
retrieving revision 1.153
retrieving revision 1.154
diff -u -d -r1.153 -r1.154
--- crypto.c	15 Aug 2005 01:03:50 -0000	1.153
+++ crypto.c	26 Aug 2005 18:40:44 -0000	1.154
@@ -422,7 +422,7 @@
   /* Read the file into a string. */
   contents = read_file_to_str(keyfile, 0);
   if (!contents) {
-    log_fn(LOG_WARN, "Error reading private key from %s", keyfile);
+    log_fn(LOG_WARN, "Error reading private key from \"%s\"", keyfile);
     return -1;
   }
 
@@ -1550,7 +1550,7 @@
   for (i = 0; filenames[i]; ++i) {
     fd = open(filenames[i], O_RDONLY, 0);
     if (fd<0) continue;
-    log_fn(LOG_INFO, "Seeding RNG from %s", filenames[i]);
+    log_fn(LOG_INFO, "Seeding RNG from \"%s\"", filenames[i]);
     n = read_all(fd, buf, sizeof(buf), 0);
     close(fd);
     if (n != sizeof(buf)) {

Index: tortls.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/common/tortls.c,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -d -r1.100 -r1.101
--- tortls.c	12 Aug 2005 17:26:43 -0000	1.100
+++ tortls.c	26 Aug 2005 18:40:44 -0000	1.101
@@ -652,7 +652,7 @@
   if (lenout == -1)
     goto error;
   if (((int)strspn(buf, LEGAL_NICKNAME_CHARACTERS)) < lenout) {
-    log_fn(LOG_WARN, "Peer certificate nickname '%s' has illegal characters.",
+    log_fn(LOG_WARN, "Peer certificate nickname \"%s\" has illegal characters.",
            buf);
     if (strchr(buf, '.'))
       log_fn(LOG_WARN, "  (Maybe it is not really running Tor at its advertised OR port.)");

Index: util.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/common/util.c,v
retrieving revision 1.216
retrieving revision 1.217
diff -u -d -r1.216 -r1.217
--- util.c	26 Aug 2005 07:37:07 -0000	1.216
+++ util.c	26 Aug 2005 18:40:44 -0000	1.217
@@ -889,22 +889,22 @@
   }
   if ((fd = open(tempname, O_WRONLY|O_CREAT|O_TRUNC|(bin?O_BINARY:O_TEXT), 0600))
       < 0) {
-    log(LOG_WARN, "Couldn't open %s for writing: %s", tempname,
+    log(LOG_WARN, "Couldn't open \"%s\" for writing: %s", tempname,
         strerror(errno));
     goto err;
   }
   result = write_all(fd, str, len, 0);
   if (result < 0 || (size_t)result != len) {
-    log(LOG_WARN, "Error writing to %s: %s", tempname, strerror(errno));
+    log(LOG_WARN, "Error writing to \"%s\": %s", tempname, strerror(errno));
     close(fd);
     goto err;
   }
   if (close(fd)) {
-    log(LOG_WARN,"Error flushing to %s: %s", tempname, strerror(errno));
+    log(LOG_WARN,"Error flushing to \"%s\": %s", tempname, strerror(errno));
     goto err;
   }
   if (replace_file(tempname, fname)) {
-    log(LOG_WARN, "Error replacing %s: %s", fname, strerror(errno));
+    log(LOG_WARN, "Error replacing \"%s\": %s", fname, strerror(errno));
     goto err;
   }
   tor_free(tempname);
@@ -937,13 +937,13 @@
   r = stat(f, &statbuf);
   tor_free(f);
   if (r < 0) {
-    log_fn(LOG_INFO,"Could not stat %s.",filename);
+    log_fn(LOG_INFO,"Could not stat \"%s\".",filename);
     return NULL;
   }
 
   fd = open(filename,O_RDONLY|(bin?O_BINARY:O_TEXT),0);
   if (fd<0) {
-    log_fn(LOG_WARN,"Could not open %s.",filename);
+    log_fn(LOG_WARN,"Could not open \"%s\".",filename);
     return NULL;
   }
 
@@ -951,7 +951,7 @@
 
   r = read_all(fd,string,statbuf.st_size,0);
   if (r<0) {
-    log_fn(LOG_WARN,"Error reading from file '%s': %s", filename,
+    log_fn(LOG_WARN,"Error reading from file \"%s\": %s", filename,
            strerror(errno));
     tor_free(string);
     close(fd);
@@ -962,7 +962,7 @@
   if (bin && r != statbuf.st_size) {
     /* If we're in binary mode, then we'd better have an exact match for
      * size.  Otherwise, win32 encoding may throw us off, and that's okay. */
-    log_fn(LOG_WARN,"Could read only %d of %ld bytes of file '%s'.",
+    log_fn(LOG_WARN,"Could read only %d of %ld bytes of file \"%s\".",
            r, (long)statbuf.st_size,filename);
     tor_free(string);
     close(fd);
@@ -1078,7 +1078,7 @@
       else
         username = tor_strdup(filename+1);
       if (!(home = get_user_homedir(username))) {
-        log_fn(LOG_WARN,"Couldn't get homedir for %s",username);
+        log_fn(LOG_WARN,"Couldn't get homedir for \"%s\"",username);
         tor_free(username);
         return NULL;
       }
@@ -1235,7 +1235,7 @@
   } else if (tor_inet_aton(address, &in) != 0) {
     *addr_out = ntohl(in.s_addr);
   } else {
-    log_fn(LOG_WARN, "Malformed IP %s in address pattern; rejecting.",address);
+    log_fn(LOG_WARN, "Malformed IP \"%s\" in address pattern; rejecting.",address);
     goto err;
   }
 
@@ -1257,7 +1257,7 @@
     } else if (tor_inet_aton(mask, &in) != 0) {
       *mask_out = ntohl(in.s_addr);
     } else {
-      log_fn(LOG_WARN, "Malformed mask %s on address range; rejecting.",
+      log_fn(LOG_WARN, "Malformed mask \"%s\" on address range; rejecting.",
              mask);
       goto err;
     }
@@ -1276,11 +1276,11 @@
       *port_max_out = (uint16_t) tor_parse_long(port, 10, 1, 65535, NULL,
                                                 &endptr);
       if (*endptr || !*port_max_out) {
-      log_fn(LOG_WARN, "Malformed port %s on address range rejecting.",
+      log_fn(LOG_WARN, "Malformed port \"%s\" on address range rejecting.",
              port);
       }
     } else if (*endptr || !*port_min_out) {
-      log_fn(LOG_WARN, "Malformed port %s on address range; rejecting.",
+      log_fn(LOG_WARN, "Malformed port \"%s\" on address range; rejecting.",
              port);
       goto err;
     } else {
@@ -1476,7 +1476,7 @@
     desired_cwd = "/";
    /* Don't hold the wrong FS mounted */
   if (chdir(desired_cwd) < 0) {
-    log_fn(LOG_ERR,"chdir to %s failed. Exiting.",desired_cwd);
+    log_fn(LOG_ERR,"chdir to \"%s\" failed. Exiting.",desired_cwd);
     exit(1);
   }
 
@@ -1514,7 +1514,7 @@
   FILE *pidfile;
 
   if ((pidfile = fopen(filename, "w")) == NULL) {
-    log_fn(LOG_WARN, "Unable to open %s for writing: %s", filename,
+    log_fn(LOG_WARN, "Unable to open \"%s\" for writing: %s", filename,
            strerror(errno));
   } else {
     fprintf(pidfile, "%d\n", (int)getpid());