Changeset 5754:b23d79c13370 in roaraudio for libroar/socket.c


Ignore:
Timestamp:
11/16/12 16:49:56 (11 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

avoid getenv() and use more portable roar_env_get(). Also improved security as we enfore const now on bufferes obtained from the env.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/socket.c

    r5745 r5754  
    401401 
    402402int roar_socket_connect (int type, const char * host, int port) { 
    403  char * proxy_type = getenv("ROAR_PROXY"); 
     403 const char * proxy_type = roar_env_get("ROAR_PROXY"); 
    404404 
    405405 ROAR_DBG("roar_socket_connect(host='%s', port=%i) = ?", host, port); 
     
    874874 int    proxy_port = -1; 
    875875 char   proxy_host[ROAR_SOCKET_MAX_HOSTNAMELEN]; 
    876  char * proxy_addr = NULL; 
     876 const char * proxy_addr = NULL; 
    877877 int    i; 
    878878 int    fh = -1; 
    879  char * user = NULL, * pw = NULL, * opts = NULL; 
     879 const char * user = NULL, * pw = NULL, * opts = NULL; 
    880880 char * sep; 
    881881 int    no_fh = 0; 
     
    895895 
    896896 if ( user == NULL ) 
    897   user = getenv("USER"); 
     897  user = roar_env_get("USER"); 
    898898 
    899899 // TODO: change this so we support listen() proxys (ssh -R) 
     
    902902 
    903903 if ( !strncmp(proxy_type, "socks", 5) ) { 
    904   proxy_addr = getenv("socks_proxy"); 
     904  proxy_addr = roar_env_get("socks_proxy"); 
    905905 
    906906  proxy_port = 9050; // TOR's default port 
     
    908908  proxy_port = 8080; 
    909909 
    910   if ( (proxy_addr = getenv("http_proxy")) == NULL ) 
    911    proxy_addr = getenv("https_proxy"); 
     910  if ( (proxy_addr = roar_env_get("http_proxy")) == NULL ) 
     911   proxy_addr = roar_env_get("https_proxy"); 
    912912 
    913913  if ( proxy_addr == NULL ) 
     
    918918 } else if ( !strncmp(proxy_type, "ssh", 3) ) { 
    919919  proxy_port = 22; 
    920   proxy_addr = getenv("ssh_proxy"); 
     920  proxy_addr = roar_env_get("ssh_proxy"); 
    921921  no_fh      = 1; 
    922922 } 
     
    11051105#ifdef ROAR_HAVE_BIN_SSH 
    11061106static int roar_socket_open_ssh    (int mode, int fh, const char * host, int port, const char * user, const char * pw, const char * opts) { 
    1107  char * proxy_addr = getenv("ssh_proxy"); 
     1107 const char * proxy_addr = roar_env_get("ssh_proxy"); 
    11081108 char * sep; 
    11091109 char   cmd[1024] = {0}, rcmd[1024] = {0}; 
Note: See TracChangeset for help on using the changeset viewer.