[or-cvs] r9466: Audit non-const char arguments; make a lot more of them cons (in tor/trunk: . src/common src/or)

nickm at seul.org nickm at seul.org
Tue Jan 30 22:20:05 UTC 2007


Author: nickm
Date: 2007-01-30 17:19:41 -0500 (Tue, 30 Jan 2007)
New Revision: 9466

Modified:
   tor/trunk/
   tor/trunk/src/common/compat.c
   tor/trunk/src/common/compat.h
   tor/trunk/src/common/tortls.c
   tor/trunk/src/common/tortls.h
   tor/trunk/src/or/circuitbuild.c
   tor/trunk/src/or/config.c
   tor/trunk/src/or/connection.c
   tor/trunk/src/or/control.c
   tor/trunk/src/or/directory.c
   tor/trunk/src/or/or.h
Log:
 r11607 at catbus:  nickm | 2007-01-30 17:19:27 -0500
 Audit non-const char arguments; make a lot more of them const.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r11607] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/common/compat.c
===================================================================
--- tor/trunk/src/common/compat.c	2007-01-30 22:19:31 UTC (rev 9465)
+++ tor/trunk/src/common/compat.c	2007-01-30 22:19:41 UTC (rev 9466)
@@ -645,7 +645,7 @@
  * success.  On failure, log and return -1.
  */
 int
-switch_id(char *user, char *group)
+switch_id(const char *user, const char *group)
 {
 #ifndef MS_WINDOWS
   struct passwd *pw = NULL;

Modified: tor/trunk/src/common/compat.h
===================================================================
--- tor/trunk/src/common/compat.h	2007-01-30 22:19:31 UTC (rev 9465)
+++ tor/trunk/src/common/compat.h	2007-01-30 22:19:41 UTC (rev 9466)
@@ -282,7 +282,7 @@
 void set_uint32(char *cp, uint32_t v) ATTR_NONNULL((1));
 
 int set_max_file_descriptors(unsigned long limit, unsigned long cap);
-int switch_id(char *user, char *group);
+int switch_id(const char *user, const char *group);
 #ifdef HAVE_PWD_H
 char *get_user_homedir(const char *username);
 #endif

Modified: tor/trunk/src/common/tortls.c
===================================================================
--- tor/trunk/src/common/tortls.c	2007-01-30 22:19:31 UTC (rev 9465)
+++ tor/trunk/src/common/tortls.c	2007-01-30 22:19:41 UTC (rev 9466)
@@ -538,7 +538,7 @@
  * TOR_TLS_WANTREAD, or TOR_TLS_WANTWRITE.
  */
 int
-tor_tls_write(tor_tls_t *tls, char *cp, size_t n)
+tor_tls_write(tor_tls_t *tls, const char *cp, size_t n)
 {
   int r, err;
   tor_assert(tls);

Modified: tor/trunk/src/common/tortls.h
===================================================================
--- tor/trunk/src/common/tortls.h	2007-01-30 22:19:31 UTC (rev 9465)
+++ tor/trunk/src/common/tortls.h	2007-01-30 22:19:41 UTC (rev 9466)
@@ -55,7 +55,7 @@
 int tor_tls_verify(int severity, tor_tls_t *tls, crypto_pk_env_t **identity);
 int tor_tls_check_lifetime(tor_tls_t *tls, int tolerance);
 int tor_tls_read(tor_tls_t *tls, char *cp, size_t len);
-int tor_tls_write(tor_tls_t *tls, char *cp, size_t n);
+int tor_tls_write(tor_tls_t *tls, const char *cp, size_t n);
 int tor_tls_handshake(tor_tls_t *tls);
 int tor_tls_shutdown(tor_tls_t *tls);
 int tor_tls_get_pending_bytes(tor_tls_t *tls);

Modified: tor/trunk/src/or/circuitbuild.c
===================================================================
--- tor/trunk/src/or/circuitbuild.c	2007-01-30 22:19:31 UTC (rev 9465)
+++ tor/trunk/src/or/circuitbuild.c	2007-01-30 22:19:41 UTC (rev 9466)
@@ -46,7 +46,7 @@
 /********* END VARIABLES ************/
 
 static int circuit_deliver_create_cell(circuit_t *circ,
-                                       uint8_t cell_type, char *payload);
+                                       uint8_t cell_type, const char *payload);
 static int onion_pick_cpath_exit(origin_circuit_t *circ, extend_info_t *exit);
 static crypt_path_t *onion_next_hop_in_cpath(crypt_path_t *cpath);
 static int onion_extend_cpath(origin_circuit_t *circ);
@@ -468,7 +468,7 @@
  */
 static int
 circuit_deliver_create_cell(circuit_t *circ, uint8_t cell_type,
-                            char *payload)
+                            const char *payload)
 {
   cell_t cell;
   uint16_t id;
@@ -788,7 +788,8 @@
  * (If 'reverse' is true, then f_XX and b_XX are swapped.)
  */
 int
-circuit_init_cpath_crypto(crypt_path_t *cpath, char *key_data, int reverse)
+circuit_init_cpath_crypto(crypt_path_t *cpath, const char *key_data,
+                          int reverse)
 {
   crypto_digest_env_t *tmp_digest;
   crypto_cipher_env_t *tmp_crypto;
@@ -838,7 +839,7 @@
  */
 int
 circuit_finish_handshake(origin_circuit_t *circ, uint8_t reply_type,
-                         char *reply)
+                         const char *reply)
 {
   char keys[CPATH_KEY_MATERIAL_LEN];
   crypt_path_t *hop;
@@ -946,8 +947,8 @@
  * cell back.
  */
 int
-onionskin_answer(or_circuit_t *circ, uint8_t cell_type, char *payload,
-                 char *keys)
+onionskin_answer(or_circuit_t *circ, uint8_t cell_type, const char *payload,
+                 const char *keys)
 {
   cell_t cell;
   crypt_path_t *tmp_cpath;

Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c	2007-01-30 22:19:31 UTC (rev 9465)
+++ tor/trunk/src/or/config.c	2007-01-30 22:19:41 UTC (rev 9466)
@@ -1121,7 +1121,7 @@
 /** Helper: parse the config string and strdup into key/value
  * strings. Set *result to the list, or NULL if parsing the string
  * failed.  Return 0 on success, -1 on failure. Warn and ignore any
- * misformatted lines. */
+ * misformatted lines. Modifies the contents of <b>string</b>. */
 int
 config_get_lines(char *string, config_line_t **result)
 {

Modified: tor/trunk/src/or/connection.c
===================================================================
--- tor/trunk/src/or/connection.c	2007-01-30 22:19:31 UTC (rev 9465)
+++ tor/trunk/src/or/connection.c	2007-01-30 22:19:41 UTC (rev 9466)
@@ -876,7 +876,7 @@
  * On success, add conn to the list of polled connections.
  */
 int
-connection_connect(connection_t *conn, char *address,
+connection_connect(connection_t *conn, const char *address,
                    uint32_t addr, uint16_t port)
 {
   int s, inprogress = 0;

Modified: tor/trunk/src/or/control.c
===================================================================
--- tor/trunk/src/or/control.c	2007-01-30 22:19:31 UTC (rev 9465)
+++ tor/trunk/src/or/control.c	2007-01-30 22:19:41 UTC (rev 9466)
@@ -779,7 +779,8 @@
 }
 
 /** Helper for setconf and resetconf. Acts like setconf, except
- * it passes <b>use_defaults</b> on to options_trial_assign().
+ * it passes <b>use_defaults</b> on to options_trial_assign().  Modifies the
+ * contents of body.
  */
 static int
 control_setconf_helper(control_connection_t *conn, uint32_t len, char *body,
@@ -885,7 +886,8 @@
 }
 
 /** Called when we receive a SETCONF message: parse the body and try
- * to update our configuration.  Reply with a DONE or ERROR message. */
+ * to update our configuration.  Reply with a DONE or ERROR message.
+ * Modifies the contents of body.*/
 static int
 handle_control_setconf(control_connection_t *conn, uint32_t len, char *body)
 {
@@ -893,7 +895,8 @@
 }
 
 /** Called when we receive a RESETCONF message: parse the body and try
- * to update our configuration.  Reply with a DONE or ERROR message. */
+ * to update our configuration.  Reply with a DONE or ERROR message.
+ * Modifies the contents of body. */
 static int
 handle_control_resetconf(control_connection_t *conn, uint32_t len, char *body)
 {
@@ -2583,7 +2586,7 @@
  */
 static int
 handle_control_fragments(control_connection_t *conn, uint16_t command_type,
-                         uint32_t body_len, char *body)
+                         uint32_t body_len, const char *body)
 {
   if (command_type == CONTROL0_CMD_FRAGMENTHEADER) {
     if (conn->incoming_cmd) {

Modified: tor/trunk/src/or/directory.c
===================================================================
--- tor/trunk/src/or/directory.c	2007-01-30 22:19:31 UTC (rev 9465)
+++ tor/trunk/src/or/directory.c	2007-01-30 22:19:41 UTC (rev 9466)
@@ -633,7 +633,7 @@
  * Otherwise, return -1.
  */
 static int
-parse_http_url(char *headers, char **url)
+parse_http_url(const char *headers, char **url)
 {
   char *s, *start, *tmp;
 
@@ -1516,8 +1516,8 @@
  * conn-\>outbuf.  If the request is unrecognized, send a 400.
  * Always return 0. */
 static int
-directory_handle_command_get(dir_connection_t *conn, char *headers,
-                             char *body, size_t body_len)
+directory_handle_command_get(dir_connection_t *conn, const char *headers,
+                             const char *body, size_t body_len)
 {
   size_t dlen;
   const char *cp;
@@ -1811,8 +1811,8 @@
  * response into conn-\>outbuf.  If the request is unrecognized, send a
  * 400.  Always return 0. */
 static int
-directory_handle_command_post(dir_connection_t *conn, char *headers,
-                              char *body, size_t body_len)
+directory_handle_command_post(dir_connection_t *conn, const char *headers,
+                              const char *body, size_t body_len)
 {
   char *url = NULL;
   or_options_t *options = get_options();

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2007-01-30 22:19:31 UTC (rev 9465)
+++ tor/trunk/src/or/or.h	2007-01-30 22:19:41 UTC (rev 9466)
@@ -1892,13 +1892,13 @@
 int circuit_send_next_onion_skin(origin_circuit_t *circ);
 void circuit_note_clock_jumped(int seconds_elapsed);
 int circuit_extend(cell_t *cell, circuit_t *circ);
-int circuit_init_cpath_crypto(crypt_path_t *cpath, char *key_data,
+int circuit_init_cpath_crypto(crypt_path_t *cpath, const char *key_data,
                               int reverse);
 int circuit_finish_handshake(origin_circuit_t *circ, uint8_t cell_type,
-                             char *reply);
+                             const char *reply);
 int circuit_truncated(origin_circuit_t *circ, crypt_path_t *layer);
-int onionskin_answer(or_circuit_t *circ, uint8_t cell_type, char *payload,
-                     char *keys);
+int onionskin_answer(or_circuit_t *circ, uint8_t cell_type,
+                     const char *payload, const char *keys);
 int circuit_all_predicted_ports_handled(time_t now, int *need_uptime,
                                         int *need_capacity);
 
@@ -2059,7 +2059,7 @@
 
 void connection_expire_held_open(void);
 
-int connection_connect(connection_t *conn, char *address, uint32_t addr,
+int connection_connect(connection_t *conn, const char *address, uint32_t addr,
                        uint16_t port);
 int retry_all_listeners(int force, smartlist_t *replaced_conns,
                         smartlist_t *new_conns);



More information about the tor-commits mailing list