Changeset 5754:b23d79c13370 in roaraudio for libroar


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.

Location:
libroar
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • libroar/basic.c

    r5745 r5754  
    6969 // we keep this step to be compatible with older versions. 
    7070 if ( daemonimage == NULL || *daemonimage == 0 ) { 
    71   daemonimage = getenv("ROAR_DAEMONIMAGE"); 
     71  daemonimage = roar_env_get("ROAR_DAEMONIMAGE"); 
    7272  if ( daemonimage != NULL ) { 
    7373   ROAR_WARN("_start_server(*): Usage of $ROAR_DAEMONIMAGE is obsolete. Use ROAR_OPTIONS=daemonimage:..."); 
     
    275275#if defined(ROAR_HAVE_UNIX) 
    276276 char user_sock[128]; 
    277  char * roar_server; 
     277 const char * roar_server; 
    278278#endif 
    279279#if defined(ROAR_HAVE_LIBSLP) || !defined(ROAR_TARGET_MICROCONTROLLER) 
     
    309309 
    310310 if ( server == NULL || *server == 0 ) 
    311   server = getenv("ROAR_SERVER"); 
     311  server = roar_env_get("ROAR_SERVER"); 
    312312 
    313313#ifdef ROAR_HAVE_LIBX11 
     
    344344#ifdef ROAR_HAVE_UNIX 
    345345#ifndef ROAR_TARGET_MICROCONTROLLER 
    346   roar_server = getenv("HOME"); 
     346  roar_server = roar_env_get("HOME"); 
    347347#else 
    348348  roar_server = NULL; 
  • libroar/config.c

    r5747 r5754  
    7676 struct roar_libroar_config * config = roar_libroar_get_config_ptr(); 
    7777 static int inited = 0; 
    78  char * next; 
     78 const char * next; 
     79 char * buf; 
    7980 
    8081 if ( !inited ) { 
    8182  inited++; // we do this early so we can use ROAR_{DBG,INFO,WARN,ERR}() in roar_libroar_config_parse(). 
    8283 
    83   next = getenv("ROAR_OPTIONS"); 
     84  next = roar_env_get("ROAR_OPTIONS"); 
    8485 
    8586  if ( next != NULL ) { 
    86    roar_libroar_config_parse(next, " "); 
     87   if ( (buf = roar_mm_strdup(next)) != NULL ) { 
     88    roar_libroar_config_parse(buf, " "); 
     89    roar_mm_free(buf); 
     90   } 
    8791  } 
    8892 } 
  • libroar/enumdev.c

    r5381 r5754  
    115115  _add(new); 
    116116 
    117   new = getenv("ROAR_SERVER"); 
     117  new = roar_env_get("ROAR_SERVER"); 
    118118  _add(new); 
    119119 
     
    126126#endif 
    127127 
    128   new = getenv("SSH_CLIENT"); 
     128  new = roar_env_get("SSH_CLIENT"); 
    129129  if ( new == NULL ) 
    130    new = getenv("SSH_CONNECTION"); 
     130   new = roar_env_get("SSH_CONNECTION"); 
    131131 
    132132  if ( new != NULL ) { 
  • libroar/env.c

    r5752 r5754  
    8686 
    8787const char * roar_env_get_home(int level) { 
    88  const char * home = getenv("HOME"); 
     88 const char * home = roar_env_get("HOME"); 
    8989 
    9090 (void)level; 
  • libroar/file.c

    r5381 r5754  
    8686 const char * k; 
    8787 
    88  if ( (k = getenv("CDDA_DEVICE")) != NULL ) 
     88 if ( (k = roar_env_get("CDDA_DEVICE")) != NULL ) 
    8989  return k; 
    9090 
  • libroar/pinentry.c

    r5619 r5754  
    4545#endif 
    4646 
    47 int roar_pinentry_open (struct roar_pinentry * pe, int flags, char * display, char * tty, char * term) { 
     47int roar_pinentry_open (struct roar_pinentry * pe, int flags, const char * display, const char * tty, const char * term) { 
    4848#ifdef _CAN_OPERATE 
    4949 int in[2], out[2]; 
     
    5757 
    5858 if ( display == NULL ) 
    59   display = getenv("DISPLAY"); 
     59  display = roar_env_get("DISPLAY"); 
    6060 
    6161 if ( display == NULL ) 
     
    7373 
    7474 if ( term == NULL ) 
    75   term = getenv("TERM"); 
     75  term = roar_env_get("TERM"); 
    7676 
    7777 if ( term == NULL ) 
  • 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.